제출 #1263239

#제출 시각아이디문제언어결과실행 시간메모리
1263239blueviolet동굴 (IOI13_cave)C++20
0 / 100
6 ms580 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;



int s[5009], d[5009];
set<int> st;

void exploreCave(int N) {
    st.clear();
    for (int i = 0; i < N; i++) {
        s[i] = 0;
        d[i] = 0;
        st.insert(i);
    }

    while (true) {
        int firstClosed = tryCombination(s);
        if (firstClosed == -1) break;

        for (auto it = st.begin(); it != st.end();) {
            int pos = *it;
            s[pos] ^= 1;
            int pp = tryCombination(s);
            if (pp == -1) break;

            if (pp < firstClosed) {
                s[pos] ^= 1;
                d[pos] = pp;
                it = st.erase(it);
            } else if (pp > firstClosed) {
                d[pos] = firstClosed;
                it = st.erase(it);
                break;
            } else {
                s[pos] ^= 1;
                ++it;
            }
        }
    }
    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...