Submission #318779

#TimeUsernameProblemLanguageResultExecution timeMemory
318779Haruto810198Cave (IOI13_cave)C++17
12 / 100
903 ms868 KiB
#include <bits/stdc++.h> /******/ #include "cave.h" /******/ using namespace std; //#define int long long #define double long double #define vi vector<int> #define pii pair<int,int> #define si set<int> #define mii map<int,int> #define F first #define S second #define pb push_back #define pf push_front #define eb emplace_back #define ef emplace_front #define pob pop_back #define pof pop_front const int INF=2147483647; const int MOD=1000000007; const int mod=998244353; const double eps=1e-12; /****** int tryCombination(int guess[]){ cout<<"? "; for(int i=0;i<4;i++){ cout<<guess[i]<<" "; } cout<<endl; int ret; cin>>ret; return ret; } void answer(int state[],int pos[]){ cout<<"!"<<endl; for(int i=0;i<4;i++){ cout<<state[i]<<" "; } cout<<endl; for(int i=0;i<4;i++){ cout<<pos[i]<<" "; } cout<<endl; } ******/ void exploreCave(int n){ int state[n],pos[n]; int guess[n]; int ans; for(int j=0;j<n;j++){ state[j]=-1; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ guess[j]=0; } for(int j=0;j<i;j++){ guess[ pos[j] ]=state[j]; } ans=tryCombination(guess); if( ans>i or ans==-1 ){ state[i]=0; } else{ state[i]=1; } int l=0,r=n-1,mid; while(l<r){ mid=(l+r)/2; /***debug*** cout<<l<<" "<<r<<" "<<mid<<endl; ***debug***/ for(int j=0;j<n;j++){ guess[j]=1-state[i]; } for(int j=l;j<=mid;j++){ guess[j]=state[i]; } for(int j=0;j<i;j++){ guess[ pos[j] ]=state[j]; } ans=tryCombination(guess); if(ans>i or ans==-1){ r=mid; } else{ l=mid+1; } } pos[i]=l; /***debug*** cout<<"//"<<endl; for(int i=0;i<n;i++){ cout<<state[i]<<" "; } cout<<endl; for(int i=0;i<n;i++){ cout<<pos[i]<<" "; } cout<<endl; cout<<"//"<<endl; ***debug***/ } answer( state , pos ); } /****** signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; exploreCave(n); return 0; } ******/
#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...