# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247714 | Nightlight | Cave (IOI13_cave) | C++14 | 790 ms | 804 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;
int N;
bool found[5005];
int S[5005], D[5005];
void solve(int pos) {
int C[N];
int init;
vector<int> pen;
for(int i = 0; i < N; i++) {
if(found[i] == 0) {
pen.push_back(i);
}
C[i] = 0;
}
for(int i = 0; i < pos; i++) C[D[i]] = S[i];
int now = tryCombination(C);
if(now != pos) init = 0, S[pos] = 0;
else init = 1, S[pos] = 1;
int l = 0, r = pen.size() - 1, res;
while(l <= r) {
int mid = (l + r) >> 1;
for(int i = 0; i <= mid; i++) {
C[pen[i]] = init;
}
for(int i = mid + 1; i < pen.size(); i++) {
C[pen[i]] = !init;
}
if(tryCombination(C) != pos) {
r = mid - 1;
res = mid;
}else l = mid + 1;
}
found[pen[res]] = 1;
D[pos] = pen[res];
}
void exploreCave(int n) {
N = n;
for(int i = 0; i < N; i++) {
solve(i);
// cout << D[i] << "\n";
}
int s[n], d[n];
for(int i = 0; i < n; i++) {
d[D[i]] = i;
s[D[i]] = S[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... |