# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
970614 |
2024-04-26T19:49:07 Z |
Acanikolic |
Cave (IOI13_cave) |
C++14 |
|
1 ms |
348 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 k = 0; k < N; k++) {
int index = tryCombination(S);
if(index == -1) break;
int l = 0,r = N - 1,ans = 0;
while(l <= r) {
int mid = (l + r) / 2;
S[mid] ^= 1;
if(tryCombination(S) > index || tryCombination(S) == -1) {
ans = mid;
S[mid] ^= 1;
break;
}
S[mid] ^= 1;
if(tryCombination(S) == index) {
l = mid + 1;
}else {
r = mid - 1;
}
}
S[ans] ^= 1;
D[ans] = index;
}
int SS[N];
for(int i = 0; i < N; i++) {
SS[i] = 1;
}
for(int i = 0; i < N; i++) if(D[i] != -1) SS[i] = S[i];
for(int k = 0; k < N; k++) {
int index = tryCombination(SS);
if(index == -1) break;
int l = 0,r = N - 1,ans = 0;
while(l <= r) {
int mid = (l + r) / 2;
SS[mid] ^= 1;
if(tryCombination(SS) > index || tryCombination(SS) == -1) {
ans = mid;
SS[mid] ^= 1;
break;
}
SS[mid] ^= 1;
if(tryCombination(SS) == index) {
l = mid + 1;
}else {
r = mid - 1;
}
}
SS[ans] ^= 1;
D[ans] = index;
}
answer(S,D);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
too much calls on tryCombination() |
2 |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
348 KB |
Answer is wrong |
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 |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
348 KB |
Answer is wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |