Submission #838376

#TimeUsernameProblemLanguageResultExecution timeMemory
838376jasminCave (IOI13_cave)C++17
0 / 100
100 ms412 KiB
//IOI 2013 #include "cave.h" #include<bits/stdc++.h> using namespace std; int ask(int m, int good, int n, vector<int>& x, int comb[], int connect[]){ int ask[n]; for(int i=0; i<n; i++){ ask[i] = comb[i]; } for(int i=0; i<=m; i++){ comb[x[i]] = good; } for(int i=m+1; i<(int)x.size(); i++){ comb[x[i]] = 1-good; } return tryCombination(ask); } void exploreCave(int N) { const int n=N; vector<int> x(n); iota(x.begin(), x.end(), 0); int comb[n]; int connect[n]; for(int i=0; i<n; i++){ connect[i] = -1; } for(int i=0; i<n; i++){ int door = tryCombination(comb); int good=0; if(door == i){ good = 1; } int l=0; int r=x.size()-1; int ans=0; while(l<=r){ int m=l+(r-l)/2; int door = ask(m, good, n, x, comb, connect); if(door == -1 || i < door){ ans = m; r = m-1; } else{ l = m+1; } } comb[x[ans]] = good; connect[x[ans]] = i; x.erase(x.begin() + ans); } answer(comb, connect); }
#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...