#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
/*int tryCombination(int arr[]){
int ttmp=4;
for(int i=0;i<ttmp;i++) cout<<arr[i] <<" ";
cout<<"\n";
int s;
cin>>s;
return s;
}*/
void exploreCave(int N) {
bool one;
int arr[N],fix[N],cn[N];
for(int i=0;i<N;i++) arr[i]=fix[i]=cn[i]=0;
for(int i=0;i<N;i++){
int l=0,r=N-1;
for(int j=0;j<N;j++) if(!fix[j]) arr[j]=1;
int tmp=tryCombination(arr);
if(tmp==-1) tmp=INT_MAX;
if(tmp>i) one=true;
else one=false;
while(l<r){
int mid=(l+r)/2;
if(one){
for(int j=l;j<=mid;j++) if(!fix[j]) arr[j]=1;
for(int j=mid+1;j<=r;j++) if(!fix[j]) arr[j]=0;
tmp=tryCombination(arr);
if(tmp==-1) tmp=INT_MAX;
if(tmp>i) r=mid;
else l=mid+1;
}
else{
for(int j=l;j<=mid;j++) if(!fix[j]) arr[j]=0;
for(int j=mid+1;j<=r;j++) if(!fix[j]) arr[j]=1;
tmp=tryCombination(arr);
if(tmp==-1) tmp=INT_MAX;
if(tmp>i) r=mid;
else l=mid+1;
}
if(l==r){
arr[l]=one;
cn[l]=i;
fix[l]=1;
}
}
}
if(N==1){
if(one) arr[0]=1;
answer(arr,cn);
return;
}
/*cout<<endl <<endl <<endl;
for(int i=0;i<N;i++) cout<<arr[i] <<" ";
for(int i=0;i<N;i++) cout<<cn[i] <<" ";*/
answer(arr,cn);
}
/*int main(){
exploreCave(4);
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
149 ms |
344 KB |
Output is correct |
2 |
Correct |
92 ms |
348 KB |
Output is correct |
3 |
Correct |
183 ms |
348 KB |
Output is correct |
4 |
Correct |
103 ms |
344 KB |
Output is correct |
5 |
Correct |
133 ms |
348 KB |
Output is correct |
6 |
Correct |
149 ms |
348 KB |
Output is correct |
7 |
Correct |
160 ms |
348 KB |
Output is correct |
8 |
Incorrect |
0 ms |
356 KB |
Answer is wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
125 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
122 ms |
348 KB |
Output is correct |
7 |
Correct |
176 ms |
344 KB |
Output is correct |
8 |
Correct |
162 ms |
344 KB |
Output is correct |
9 |
Correct |
153 ms |
344 KB |
Output is correct |
10 |
Correct |
161 ms |
556 KB |
Output is correct |
11 |
Correct |
179 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
444 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 |
436 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
444 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 |
436 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
21 ms |
508 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
25 ms |
344 KB |
Output is correct |
24 |
Correct |
26 ms |
348 KB |
Output is correct |
25 |
Correct |
27 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
21 ms |
500 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
20 ms |
500 KB |
Output is correct |
31 |
Correct |
21 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
25 ms |
504 KB |
Output is correct |
36 |
Correct |
25 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
149 ms |
344 KB |
Output is correct |
2 |
Correct |
92 ms |
348 KB |
Output is correct |
3 |
Correct |
183 ms |
348 KB |
Output is correct |
4 |
Correct |
103 ms |
344 KB |
Output is correct |
5 |
Correct |
133 ms |
348 KB |
Output is correct |
6 |
Correct |
149 ms |
348 KB |
Output is correct |
7 |
Correct |
160 ms |
348 KB |
Output is correct |
8 |
Incorrect |
0 ms |
356 KB |
Answer is wrong |
9 |
Halted |
0 ms |
0 KB |
- |