# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289922 | Atill83 | Cave (IOI13_cave) | C++14 | 318 ms | 760 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 <bits/stdc++.h>
using namespace std;
const int MAXN = (int) 5e3 + 5;
int s[MAXN];
int ans[MAXN];
vector<int> rest;
int D[MAXN];
void ot(int N){
for(int i = 0; i < N; i++) cerr<<s[i]<<" ";
cerr<<endl;
}
void exploreCave(int N) {
/* ... */
for(int i = 0; i < N; i++) rest.push_back(i);
for(int i = 0; i < N; i++){
bool st = 1;
for(int j = 0; j < rest.size(); j++){
s[rest[j]] = 0;
}
int ans = tryCombination(s);
if(ans == -1 || ans > i){
st = 0;
}
int l = 0, r = rest.size() - 1;
while(l < r){
int m = (l + r) / 2;
for(int j = l; j <= m; j++){
s[rest[j]] = st;
}
for(int j = m + 1; j <= r; j++)
s[rest[j]] = !st;
//cerr<<l<<" "<<r<<endl;
//ot(N);
int ans = tryCombination(s);
if(ans == -1 || ans > i){
r = m;
}else{
l = m + 1;
}
}
//cerr<<st<<endl;
//cerr<<rest[l]<<" "<<i<<endl;
//ot(N);
s[rest[l]] = st;
D[rest[l]] = i;
swap(rest[l], rest.back());
rest.pop_back();
}
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... |