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 = 5005;
int n;
vector<pair<int, int>> v;
int s[maxn], pos[maxn], D[maxn];
bool can(int l, int r, int f, int pos){
int s1[maxn];
for(int i = 0; i < n; ++i){
s1[i] = f;
}
for(int i = l; i <= r; ++i){
s1[i] ^= 1;
}
for(auto i : v){
s1[i.first] = i.second;
}
int x = tryCombination(s1);
if(x > pos or x == -1)return 1;
else return 0;
}
void exploreCave(int N) {
n = N;
for(int i = 0; i < N; ++i){
int l = i, r = N - 1, ans = 0;
int bit = 0;
if(can(0, N - 1, 1, i)){}
else {
bit = 1;
}
while(l <= r){
int mid = (l + r) >> 1;
if(can(mid, r, bit ^ 1, i)){
ans = mid;
l = mid + 1;
}else {
r = mid - 1;
}
}
v.push_back(make_pair(ans, bit));
}
for(int i = 0; i < N; ++i){
s[v[i].first] = v[i].second;
}
for(int i = 0; i < n; ++i){
s[i] ^= 1;
D[i] = tryCombination(s);
s[i] ^= 1;
}
answer(s, D);
}
# | 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... |