이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
bool isOpen(int i, int ret){
return ret == -1 || ret > i;
}
void exploreCave(int N){
int switches[N], permu[N], ansD[N], ansP[N];
for(int i = 0; i < N; ++i){
switches[i] = i;
permu[i] = 0;
ansP[i] = 0;
ansD[i] = 0;
}
for(int i = 0; i < N; ++i){
for(int j = 0; j < N - i; ++j){
permu[switches[j]] = 0;
}
int correct;
/*cout << "PRINT PERMU\n";
for(int j = 0; j < N; ++j){
cout << permu[j] << ' ';
}
printf("check:%d\n", tryCombination(permu));*/
if(isOpen(i, tryCombination(permu))){
correct = 0;
} else {
correct = 1;
}
//printf("correct:%d\n", correct);
//cout << '\n';
int l = 0;
int r = N - i - 1;
while(l < r){
//printf("l:%d r:%d\n", l, r);
int m = (l + r) / 2;
for(int j = l; j <= m; ++j){
permu[switches[j]] = correct;
}
for(int j = m + 1; j <= r; ++j){
permu[switches[j]] = correct ^ 1;
}
if(isOpen(i, tryCombination(permu))){
r = m;
} else {
for(int j = l; j <= m; ++j){
permu[switches[j]] = correct ^ 1;
}
l = m + 1;
}
}
//printf("door[%d]:%d\n", i, switches[l]);
ansP[switches[l]] = correct;
permu[switches[l]] = correct;
ansD[switches[l]] = i;
swap(switches[l], switches[N - i - 1]);
/*cout << "ansP: ";
for(int j = 0; j < N; ++j){
cout << ansP[j] << ' ';
}
cout << "\nansD: ";
for(int j = 0; j < N; ++j){
cout << ansD[j] << ' ';
}
cout << '\n';*/
}
answer(ansP, ansD);
}
# | 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... |