#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
const int MAXN = 5e3 + 5;
int st[MAXN], con[MAXN], cnt, n, SS[MAXN], DD[MAXN];
/*
int tryCombination(int S[]){
int mn = MAXN;
for(int i=0; i<n; ++i) if(S[i] != SS[i]) mn = min(mn, DD[i]);
return mn == MAXN ? -1 : mn;
}
*/
/*
void answer(int S[], int D[]){
bool ok = true;
for(int i=0; i<n; ++i) if(S[i] != SS[i]) ok = false;
for(int i=0; i<n; ++i) if(D[i] != DD[i]) ok = false;
puts(ok ? "YES" : "NO");
}
*/
void solve(int ret){
int lo = 0, hi = n - 1, mid, res, r;
while(lo <= hi){
mid = (lo + hi)>>1;
for(int i=0; i<=mid; ++i) st[i] ^= 1;
r = tryCombination(st);
for(int i=0; i<=mid; ++i) st[i] ^= 1;
if(r != ret) hi = mid - 1, res = mid;
else lo = mid + 1;
}
st[res] ^= 1;
}
void exploreCave(int N){
n = N;
while(true){
int ret = tryCombination(st);
if(ret == -1){
for(int i=0; i<n; ++i){ st[i] ^= 1; con[i] = tryCombination(st); st[i] ^= 1; }
break;
}
solve(ret);
}
answer(st, con);
}
/*
int main(){
scanf("%d", &n);
for(int i=0; i<n; ++i) scanf("%d", &SS[i]);
for(int i=0; i<n; ++i) scanf("%d", &DD[i]);
exploreCave(n);
return 0;
}
*/
Compilation message
cave.cpp: In function 'void solve(int)':
cave.cpp:35:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
st[res] ^= 1;
~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
512 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
21 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
16 ms |
512 KB |
Output is correct |
7 |
Correct |
22 ms |
384 KB |
Output is correct |
8 |
Correct |
20 ms |
384 KB |
Output is correct |
9 |
Correct |
18 ms |
484 KB |
Output is correct |
10 |
Correct |
25 ms |
384 KB |
Output is correct |
11 |
Correct |
24 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
6 ms |
512 KB |
too much calls on tryCombination() |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
6 ms |
512 KB |
too much calls on tryCombination() |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
512 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |