제출 #1091520

#제출 시각아이디문제언어결과실행 시간메모리
1091520AndreasK동굴 (IOI13_cave)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h>
#include <cave.h>
using namespace std;
 
#define designed ios_base::sync_with_stdio(0);
#define by cin.tie(0);
#define AndreasK cout.tie(0);
//#define int long long
#define ii pair <int, int>
#define vi vector <int>
#define iii pair <int, ii>
#define vii vector <ii>
#define vc vector <char>
#define vb vector <bool>
 
void exploreCave(int n) {
    int s[n] = {}, d[n];
    int x = tryCombination(s);
    stack <int> st;
    for (int c = 0; c < n; c++) {
        s[c] ^= 1;
        int prevx = x;
        x = tryCombination(s);
        if (x == -1)
            x = 2 * n;
        if (x < prevx) {
            s[c] ^= 1;
        }
        else if (x == prevx) {
            st.push(c);
        }
        else {
            while (!st.empty()) {
                prevx = x;
                x = tryCombination(s);
                if (x == -1)
                    x = 2 * n;
                s[st.top()] ^= 1;
                if (x > prevx) {
                    st.pop();
                }
                else {
                    s[st.top()] ^= 1;
                    break;
                }
            }
        }
    }
    for (int c = 0; c < n; c++) {
        s[c] ^= 1;
        x = tryCombination(s);
        s[c] ^= 1;
        d[c] = x;
    }
    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...