이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//IOI 2013
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
int ask(int m, int good, int n, vector<int>& x, int comb[], int connect[]){
int ask[n];
for(int i=0; i<n; i++){
ask[i] = comb[i];
}
for(int i=0; i<=m; i++){
comb[x[i]] = good;
}
for(int i=m+1; i<(int)x.size(); i++){
comb[x[i]] = 1-good;
}
return tryCombination(ask);
}
void exploreCave(int N) {
const int n=N;
vector<int> x(n);
iota(x.begin(), x.end(), 0);
int comb[n];
int connect[n];
for(int i=0; i<n; i++){
connect[i] = -1;
}
for(int i=0; i<n; i++){
int door = tryCombination(comb);
int good=0;
if(door == i){
good = 1;
}
int l=0; int r=x.size()-1;
int ans=0;
while(l<=r){
int m=l+(r-l)/2;
int door = ask(m, good, n, x, comb, connect);
if(door == -1 || i < door){
ans = m;
r = m-1;
}
else{
l = m+1;
}
}
comb[x[ans]] = good;
connect[x[ans]] = i;
x.erase(x.begin() + ans);
}
answer(comb, connect);
}
# | 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... |