# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421321 | errorgorn | Cave (IOI13_cave) | C++17 | 281 ms | 580 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 "cave.h"
#include <cstdio>
#include <vector>
using namespace std;
int n;
int door[5005];
int button[5005];
int temp[5005];
vector<int> left;
void test(int i){
if (tryCombination(button)!=i){
for (int x=0;x<left.size();x++) button[left[x]]^=1;
}
int l=0,r=left.size()-1,m;
while (l!=r){
m=(l+r)>>1;
for (int x=0;x<n;x++){
temp[x]=button[x];
}
for (int x=l;x<=m;x++){
temp[left[x]]^=1;
}
if (tryCombination(temp)==i){
l=m+1;
}
else{
r=m;
}
}
door[left[l]]=i;
button[left[l]]^=1;
left.erase(left.begin()+l);
}
void exploreCave(int N) {
n=N;
for (int x=0;x<n;x++){
door[x]=x;
left.push_back(x);
}
for (int x=0;x<n;x++){
test(x);
}
answer(button,door);
}
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... |