Submission #857519

# Submission time Handle Problem Language Result Execution time Memory
857519 2023-10-06T10:33:13 Z chilinhxyzabc Cave (IOI13_cave) C++17
25 / 100
79 ms 524 KB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std; 

void exploreCave(int n) {
    int s[n], d[n];
    for(int i = 0; i < n; i++) {
        s[i] = 0;
        d[i] = -1;
    }
    for(int i = 0; i < n; i++) {
        int curDoor = tryCombination(s);
        if(curDoor == -1)
            break;
        else {
            int l = i, r = n - 1, res;
            while(l <= r) {
                int m = (l + r) / 2;
                s[m] = 1 - s[m];
                int door = tryCombination(s);
                if(curDoor == door) {
                    r = m - 1;
                } else {
                    l = m + 1;
                    res = m;
                }
                s[m] = 1 - s[m];
            }
            d[res] = curDoor;
            s[res] = 1 - s[res];
            i = res;
        }
    }
    for(int i = 0; i < n; i++) {
        if(d[i] != -1)
            continue;
        s[i] = 1 - s[i];
        int door = tryCombination(s);
        d[i] = door;
        s[i] = 1 - s[i];
    }
    answer(s, d);
}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:11:5: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |     for(int i = 0; i < n; i++) {
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 47 ms 348 KB Output is correct
3 Correct 79 ms 348 KB Output is correct
4 Correct 50 ms 348 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 41 ms 524 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 41 ms 348 KB Output is correct
13 Correct 42 ms 348 KB Output is correct
14 Correct 41 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 348 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 8 ms 348 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB too much calls on tryCombination()
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB too much calls on tryCombination()
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 47 ms 348 KB Output is correct
3 Correct 79 ms 348 KB Output is correct
4 Correct 50 ms 348 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 41 ms 524 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 41 ms 348 KB Output is correct
13 Correct 42 ms 348 KB Output is correct
14 Correct 41 ms 504 KB Output is correct
15 Correct 8 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 8 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Correct 9 ms 348 KB Output is correct
23 Correct 8 ms 348 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 8 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Incorrect 1 ms 348 KB too much calls on tryCombination()
31 Halted 0 ms 0 KB -