# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
556249 |
2022-05-02T16:03:45 Z |
Zanite |
Cave (IOI13_cave) |
C++17 |
|
295 ms |
432 KB |
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
int toggle[N], correspondence[N];
bool answered[N];
memset(toggle, 0, sizeof(toggle));
memset(correspondence, 0, sizeof(correspondence));
memset(answered, 0, sizeof(answered));
for (int i = 0; i < N; i++) {
// check the correct position of the switch that handles the i-th door
int correctPos = 0;
for (int s = 0; s < N; s++) {
if (!answered[s]) {toggle[s] = 0;}
}
if (tryCombination(toggle) == i) {
for (int s = 0; s < N; s++) {
if (!answered[s]) {toggle[s] = 1;}
}
correctPos = 1;
}
// search which switch connects to the i-th door
deque<int> guesses;
for (int s = 0; s < N; s++) {
if (!answered[s]) {guesses.push_back(s);}
}
while (guesses.size() > 1) {
// guess the left half of deque
bool removeLeft = 0;
for (int g = 0; g < (guesses.size() >> 1); g++) {
toggle[guesses[g]] = 1 - correctPos;
}
if (tryCombination(toggle) != i) {
removeLeft = 1;
}
for (int g = 0; g < (guesses.size() >> 1); g++) {
toggle[guesses[g]] = correctPos;
}
if (removeLeft) {
for (int g = 0; g < (guesses.size() >> 1); g++) {
guesses.pop_front();
}
} else {
for (int g = (guesses.size() >> 1); g < guesses.size(); g++) {
guesses.pop_back();
}
}
}
correspondence[guesses[0]] = i;
answered[guesses[0]] = 1;
}
answer(toggle, correspondence);
}
Compilation message
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:35:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int g = 0; g < (guesses.size() >> 1); g++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~
cave.cpp:41:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int g = 0; g < (guesses.size() >> 1); g++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~
cave.cpp:46:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (int g = 0; g < (guesses.size() >> 1); g++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~
cave.cpp:50:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for (int g = (guesses.size() >> 1); g < guesses.size(); g++) {
| ~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
230 ms |
412 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
295 ms |
432 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
60 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
81 ms |
348 KB |
Output is correct |
24 |
Correct |
79 ms |
364 KB |
Output is correct |
25 |
Correct |
75 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
73 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
59 ms |
340 KB |
Output is correct |
31 |
Correct |
61 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
77 ms |
352 KB |
Output is correct |
36 |
Correct |
73 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
230 ms |
412 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |