이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |