| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1082622 | KALARRY | 동굴 (IOI13_cave) | C++14 | 0 ms | 0 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//chockolateman
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
int pos[5005];
int query[5005];
int ask_Query(vector<int> S)
{
    for(int i = 0 ; i < N ; i++)
        query[i] = S[i];
    return tryCombination(query);
}
bool check(vector<int> combo,int door)
{
    int res = ask_Query(combo);
    return (res > door || res == -1);
}
void exploreCave(int N)
{
    vector<int> cur;
    for(int i = 0 ; i < N ; i++)
    {
        pos[i] = -1;
        cur.push_back(0);
    }
    for(int i = 0 ; i < N ; i++)
    {
        int res = ask_Query(cur);
        if(res > i || res==-1)
            for(int j = 0 ; j < N ; j++)
                if(pos[j]==-1)
                    cur[j] = (cur[j] + 1)%2;
        int cur_switch = -1;
        for(int b = N ; b >= 1 ; b/=2)
        {
            if(cur_switch + b > N)
                continue;
            vector<int> temp = cur;
            for(int j = 0 ; j <= cur_switch + b; j++)
                if(pos[j]==-1)
                    temp[j] = (temp[j] + 1)%2; 
            while(cur_switch + b < N && !check(temp,i))
            {
                cur_switch += b;
                for(int j = 0 ; j <= cur_switch ; j++)
                    if(pos[j]==-1)
                        cur[j] = (cur[j] + 1)%2; 
                for(int j = 0 ; j <= cur_switch + b; j++)
                    if(pos[j]==-1)
                        temp[j] = (temp[j] + 1)%2; 
            }
        }
        cur_switch++;
        pos[cur_switch] = i;
        cur[cur_switch] = (cur[cur_switch] + 1)%2;
    }
    ask_Query(cur);
    answer(query,pos);
}
