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"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
const int N = 5e3+5;
int n, vis[N], CNT = 1;
int SS[N], DD[N];
// int tryCombination(int S[]){
// for (int i = 0; i < n; i++){
// if (S[DD[i]] != SS[DD[i]]) return i;
// }
// return -1;
// }
// void answer(int S[], int D[]){
// if (CNT > 70000){
// cout << "Incorrect";
// exit(0);
// }
// for (int i = 0; i < n; i++){
// if (S[i] != SS[i] or D[i] != DD[i]){
// cout << "Incorrect";
// exit(0);
// }
// }
// cout << "Correct";
// }
void exploreCave(int n){
int S[n], D[n];
for (int i = 0; i < n; i++){
S[i] = 0;
}
int x = tryCombination(S);
for (int i = 0; i < n; i++){
int l = 0, r = n-1, pos = -1;
while(l <= r){
int md = (l+r)>>1;
for (int j = md; j < n; j++){
if (!vis[j]) S[j] = !S[j];
}
// if (CNT == 70000) assert(1);
CNT++;
int new_x = tryCombination(S);
if (i == x){
if (new_x == x) r = md - 1;
else{
pos = md;
l = md + 1;
}
}else{
if (new_x == i){
pos = md;
l = md + 1;
}else r = md - 1;
}
for (int j = md; j < n; j++){
if (!vis[j]) S[j] = !S[j];
}
}
assert(pos != -1);
D[i] = pos;
vis[pos] = 1;
if (i == x){
S[pos] = !S[pos];
// if (CNT == 70000) assert(1);
CNT++;
x = tryCombination(S);
}
}
answer(S, D);
}
// int main ()
// {
// cin >> n;
// for (int i = 0; i < n; i++){
// SS[i] = 0;
// // cin >> SS[i];
// }
// for (int i = 0; i < n; i++){
// cin >> DD[i];
// }
// exploreCave(n);
// }
# | 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... |