# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
569587 | Aurora2005 | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include"cave.h";
using namespace std;
void exploreCave(int N){
vector<pair<int,int>> ans(N);
for(int i=0;i<N;i++) ans[i] = make_pair(-1,-1);
for(int i=0;i<N;i++){
vector<int> First(N);
for(int j=0;j<N;j++){
if(ans[j].first == -1) First[j] = 0;
else First[j] = ans[j].second;
}
if(tryCombination(First) == i+1){
int l = 0,r = N;
while(r-l > 1){
int m = (l+r)/2;
vector<int> S(N);
for(int j=0;j<N;j++){
if(ans[j].first){
if(j < m) S[j] = 0;
else S[j] = 1;
}
else S[j] = ans[j].second;
}
if(tryCombination(S) == i+1) r = m;
else l = m;
}
ans[l].first = i+1;
ans[l].second = 1;
}
else{
int l = 0,r = N;
while(r-l > 1){
int m = (l+r)/2;
vector<int> S(N);
for(int j=0;j<N;j++){
if(ans[j].first){
if(j < m) S[j] = 0;
else S[j] = 1;
}
else S[j] = ans[j].second;
}
if(tryCombination(S) == i+1) l = m;
else r = m;
}
ans[l].first = i+1;
ans[l].second = 0;
}
}
vector<int> ansS(N),ansD(N);
for(int i=0;i<N;i++){
ansS[i] = ans[i].second;
ansD[i] = ans[i].first;
}
answer(ansS,ansD);
}