# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
277544 | jainbot27 | 동굴 (IOI13_cave) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
//okay so you cant actually use tryCombination 70k times
/*
int tryCombination(vector<int> a){
for(int i:a){
cout << i << " ";
}
cout << endl;
int x; cin >> x;
return x;
}
*/
//void answer(vector<int> s, vector<int> d){
//}
void exploreCave(int n){
vector<int> cur(n,0), done(n,0), ans(n,0), ans2(n, 0);
for(int i=0; i < n; i++){
vector<int> mirror = cur;
if(tryCombination(mirror) == i){
for(int j = 0; j < n; j++){
if(!done[j])
cur[j] ^=1;
}
}
mirror = cur;
int lo = 0, hi = n-1;
while(lo < hi){
int mid = (lo + hi)/2;
for(int j = lo; j <= mid; j++){
if(!done[j])
mirror[j] ^= 1;
}
//cerr << "LO " << lo << " HI " << hi << endl;
int x = tryCombination(mirror);
if(x != i){
//for(int j = lo; j <= mid; j++){
//if(!done[j])
//mirror[j]^=1;
//}
lo = mid + 1;
}
else{
//for(int j = mid + 1; j <= hi; j++){
//if(!done[j])
//mirror[j]^=1;
//}
hi = mid;
}
mirror = cur;
}
//cerr << "LO " << lo << endl;
//for(int j=0; j <n; j++){
//cerr << mirror[j] << " ";
//}
//cerr << endl;
//cur[lo] ^= 1;
done[lo] = 1;
ans[lo] = i;
ans2[lo] = cur[lo];
//cerr << "NEW" << endl;
}
//for(int i=0; i < n; i++){
//cout << ans[i] << " " << ans2[i] << endl;
//}
answer(ans2, ans);
exit(0);
}
/*
int main(){
exploreCave(4);
}
*/