Submission #915225

#TimeUsernameProblemLanguageResultExecution timeMemory
915225LCJLYCave (IOI13_cave)C++14
0 / 100
180 ms600 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int n) { //determine first switch int arr[n]; memset(arr,0,sizeof(arr)); int visited[n]; memset(visited,0,sizeof(visited)); int ans[n]; for(int x=0;x<n;x++){ for(int y=0;y<n;y++){ if(!visited[y]) arr[y]=0; } int hold=tryCombination(arr); if(hold==-1) hold=n; bool amos=false; if(hold<=x) amos=true; int l=0; int r=n-1; int best=l; int mid; while(l<=r){ mid=(l+r)/2; for(int y=0;y<n;y++){ if(y<=mid&&!visited[y]){ arr[y]=!amos; } else if(!visited[y]) arr[y]=amos; } int hold2=tryCombination(arr); if(hold2==-1) hold2=n; if(hold2<=x){ best=mid; r=mid-1; } else l=mid+1; } visited[best]=true; arr[best]=!amos; ans[x]=best; } answer(arr,ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...