# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1007832 |
2024-06-25T14:15:31 Z |
Newtonabc |
Cave (IOI13_cave) |
C++14 |
|
167 ms |
600 KB |
#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>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;
if(l==r) arr[l]=1,cn[l]=i,fix[l]=1;
continue;
}
else{
l=mid+1;
if(l==r) arr[l]=1,cn[l]=i,fix[l]=1;
continue;
}
}
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;
if(l==r) arr[l]=0,cn[l]=i,fix[l]=1;
continue;
}
else{
l=mid+1;
if(l==r) arr[l]=0,cn[l]=i,fix[l]=1;
continue;
}
}
}
}
/*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);
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
348 KB |
Output is correct |
2 |
Incorrect |
87 ms |
536 KB |
Answer is wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
132 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
440 KB |
Output is correct |
6 |
Correct |
141 ms |
560 KB |
Output is correct |
7 |
Correct |
159 ms |
348 KB |
Output is correct |
8 |
Correct |
167 ms |
600 KB |
Output is correct |
9 |
Correct |
162 ms |
560 KB |
Output is correct |
10 |
Correct |
162 ms |
344 KB |
Output is correct |
11 |
Correct |
162 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Answer is wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Answer is wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
348 KB |
Output is correct |
2 |
Incorrect |
87 ms |
536 KB |
Answer is wrong |
3 |
Halted |
0 ms |
0 KB |
- |