제출 #1344800

#제출 시각아이디문제언어결과실행 시간메모리
1344800sdanCave (IOI13_cave)C++20
0 / 100
31 ms500 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second

void exploreCave(int n) {
    int s[n], d[n]; for(int i = 0; i < n; ++i) s[i] = 0, d[i] = -1;
    int k = -1;

    for(int i = 0; i < n; ++i) {
        k = tryCombination(s);
        if(k != i) for(int i = 0; i < n; ++i)
            if(d[i] == -1) s[i] = s[i] ^ 1;

        int l = 0, r = n;
        while(l + 1 < r) {
            int m = (l + r) / 2;

            for(int i = l; i < m; ++i)
                if(d[i] == -1) s[i] = s[i] ^ 1;

            k = tryCombination(s);
            if(k == i) l = m;
            else {
                for(int i = l; i < m; ++i)
                    if(d[i] == -1) s[i] = s[i] ^ 1;
                r = m;
            }
        }

        d[l] = i;
        if(k == i) s[l] = s[l] ^ 1;
    }

    answer(s, d);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...