Submission #1263232

#TimeUsernameProblemLanguageResultExecution timeMemory
1263232bluevioletCave (IOI13_cave)C++20
0 / 100
6 ms580 KiB
#include <bits/stdc++.h>
using namespace std;

extern "C" {
    int tryCombination(int S[]);
    void answer(int S[], int D[]);
    void exploreCave(int N);
}

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

void exploreCave(int N) {
    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...