이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
/*int n; //
int tryCombination(int v[]){
for(int i = 0; i < n; i++) cout << v[i] << " ";
cout << endl;
int rep; cin >> rep;
return rep;
}
void answer(int s[], int d[]){
cout << "S: "<<endl;
for(int i = 0; i < n; i++) cout << s[i] << " ";
cout << endl << "D: "<<endl;
for(int i = 0; i < n; i++) cout << d[i] << " ";
}*/
void exploreCave(int N) {
//n = N; //
vector<int> correct(N, -1);
vector<int> switches(N, -1);
for(int i = 0; i < N; i++){
if(correct[i] == -1){
int v[N];
for(int j = 0; j < N; j++) v[j] = 0;
for(int j = 0; j < i; j++) v[switches[j]] = correct[j];
int x = tryCombination(v);
if(x == -1){
for(int j = i; j < N; j++) correct[j] = 0;
}else{
for(int j = i; j < x; j++) correct[j] = 0;
correct[x] = 1;
}
}
/*cout << "I'm on I: "<<i << " correct: "<<endl;
for(int x : correct) cout << x << " ";
cout << endl << "Switches: "<<endl;
for(int x : switches) cout << x << " ";
cout << endl;*/
int lo = 0;
int hi = N - 1;
while(lo < hi){
int mid = (lo + hi) / 2;
int v[N];
for(int j = 0; j < N; j++) v[j] = 1 - correct[i];
for(int j = lo; j <= mid; j++) v[j] = correct[i];
for(int j = 0; j < i; j++){
v[switches[j]] = correct[j];
}
int x = tryCombination(v);
if(x > i || x == -1){
hi = mid;
}else lo = mid + 1;
}
switches[i] = lo;
}
int d[N];
for(int i = 0; i < N; i++){
d[switches[i]] = i;
}
int s[N];
for(int i = 0; i < N; i++){
s[switches[i]] = correct[i];
}
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... |