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;
void exploreCave(int N) {
int n = N;
int correctPosition[n];
int connectedDoor[n];
int tryCombinationArray[n];
for(int i = 0; i < n; ++i) {
correctPosition[i] = -1;
connectedDoor[i] = -1;
tryCombinationArray[i] = 0;
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
if(correctPosition[j] == -1) {
tryCombinationArray[j] = 0;
} else {
tryCombinationArray[j] = correctPosition[j];
}
}
int pos = tryCombination(tryCombinationArray);
if(pos == i) pos = 1;
else pos = 0;
int l = 0, r = n;
int swappedTo = 0;
while(l < r - 1) {
int ce = (l + r) / 2;
for(int j = l; j < ce; ++j) {
if(correctPosition[j] == -1) {
tryCombinationArray[j] = 1 - tryCombinationArray[j];
swappedTo = tryCombinationArray[j];
} else {
tryCombinationArray[j] = correctPosition[j];
}
}
int result = tryCombination(tryCombinationArray);
if(((pos == swappedTo) && (result != i)) || ((pos != swappedTo) && (result == i))) {
r = ce;
} else {
l = ce;
}
}
connectedDoor[l] = i;
correctPosition[l] = pos;
/*cout << i << ":\n";
for(int j = 0; j < n; ++j) cout << connectedDoor[j] << " ";
cout << "\n";
for(int j = 0; j < n; ++j) cout << correctPosition[j] << " ";
cout << "\n";*/
}
answer(correctPosition, connectedDoor);
}
# | 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... |