This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 5000
int v[MAX_N];
bool used[MAX_N];
void convert(int idx, int val){
for(int i = 0; i<= idx; i++){
if(used[i]) continue;
v[i] = val;
}
}
void exploreCave(int N) {
/* ... */
//int v[N];
for(int i = 0; i<N; i++){
v[i] = 0;
}
int s[N];
// Busco combinacio correcte
for(int i = 0; i<N; i++){
bool ok = 0;
int l = -1; int r = N-1;
int val = 0;
convert(N-1,0);
if(i == 2){
/*cout<<"V ";
for(int i = 0; i<N; i++) cout<<v[i]<<" ";
cout<<endl;*/
}
if(tryCombination(v) == i) val = 1;
convert(N-1,val^1);
while(r > l+1){
int m = (l+r)/2;
convert(m,val);
// si s'ha obert,
int x = tryCombination(v);
if(x == i){
//tancat
l = m;
}
else r = m;
convert(m,val^1);
}
//cout<<i<<" "<<l<<" "<<r<<" "<<val<<endl;
used[r] = 1;
v[r] = val;
s[r] = i;
}
answer(v,s);
//for(int i = 0; i<N; i++) cout<<v[i]<<" "; cout<<endl;
//for(int i = 0; i<N; i++) cout<<s[i]<<" "; cout<<endl;
return;
}
Compilation message (stderr)
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:25:10: warning: unused variable 'ok' [-Wunused-variable]
25 | bool ok = 0;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |