# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1002243 |
2024-06-19T11:19:55 Z |
toast12 |
Cave (IOI13_cave) |
C++14 |
|
269 ms |
976 KB |
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int N) {
int s[N], d[N];
set<int> a;
for (int i = 0; i < N; i++) {
s[i] = -1;
d[i] = -1;
a.insert(i);
}
// iterate over all doors and find out which switch opens the ith door
for (int i = 0; i < N; i++) {
// find which switch unlocks door i
set<int> b = a;
for (auto it = a.begin(); it != a.end(); it++) {
int j = *it;
if (s[j] != -1)
continue;
// try setting the current switch to down position
s[j] = 0;
int x = tryCombination(s);
if (x == i+1 || x == -1) {
// the current switch unlocks the current door
d[j] = i;
b.erase(b.find(j));
break;
}
// try setting the switch to up position
s[j] = 1;
x = tryCombination(s);
if (x == i+1 || x == -1) {
d[j] = i;
b.erase(b.find(j));
break;
}
s[j] = -1;
}
swap(a, b);
}
answer(s, d);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
876 KB |
Output is correct |
2 |
Correct |
184 ms |
880 KB |
Output is correct |
3 |
Correct |
227 ms |
856 KB |
Output is correct |
4 |
Correct |
167 ms |
888 KB |
Output is correct |
5 |
Correct |
234 ms |
860 KB |
Output is correct |
6 |
Correct |
244 ms |
856 KB |
Output is correct |
7 |
Correct |
255 ms |
968 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 |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
255 ms |
972 KB |
Output is correct |
13 |
Correct |
260 ms |
860 KB |
Output is correct |
14 |
Correct |
261 ms |
976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
972 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
3 ms |
860 KB |
too much calls on tryCombination() |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Incorrect |
2 ms |
600 KB |
too much calls on tryCombination() |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
876 KB |
Output is correct |
2 |
Correct |
184 ms |
880 KB |
Output is correct |
3 |
Correct |
227 ms |
856 KB |
Output is correct |
4 |
Correct |
167 ms |
888 KB |
Output is correct |
5 |
Correct |
234 ms |
860 KB |
Output is correct |
6 |
Correct |
244 ms |
856 KB |
Output is correct |
7 |
Correct |
255 ms |
968 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 |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
255 ms |
972 KB |
Output is correct |
13 |
Correct |
260 ms |
860 KB |
Output is correct |
14 |
Correct |
261 ms |
976 KB |
Output is correct |
15 |
Correct |
269 ms |
972 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Incorrect |
3 ms |
860 KB |
too much calls on tryCombination() |
18 |
Halted |
0 ms |
0 KB |
- |