# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
348081 | laoriu | Cave (IOI13_cave) | C++14 | 504 ms | 748 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"
#define pb push_back
using namespace std;
const int MAX=5005;
bool ok[MAX];
int S[MAX],D[MAX];
void exploreCave(int n){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)if(!D[j])
S[j]=0;
else S[j]=ok[j];
int x=tryCombination(S);
if(x==i){
int ans;
int b=0,e=n-1;
while(b<=e){
int m=b+e>>1;
for(int j=0;j<n;j++)if(!D[j])
S[j]=(j<=m);
else S[j]=ok[j];
int x=tryCombination(S);
if(x==i)b=m+1;
else{
e=m-1;
ans=m;
}
}
D[ans]=i+1;
ok[ans]=1;
}
else{
int ans;
int b=0,e=n-1;
while(b<=e){
int m=b+e>>1;
for(int j=0;j<n;j++)if(!D[j])
S[j]=(j>m);
else S[j]=ok[j];
int x=tryCombination(S);
if(x==i)b=m+1;
else{
e=m-1;
ans=m;
}
}
D[ans]=i+1;
ok[ans]=0;
}
}
for(int i=0;i<n;i++) D[i]--;
answer(S,D);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |