#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 id = st.begin(); id != st.end();) {
int pos = *id;
s[pos] ^= 1;
int pp = tryCombination(s);
if (pp == -1) break;
if (pp < firstClosed) {
s[pos] ^= 1;
d[pos] = pp;
id = st.erase(id); // xoá và cập nhật iterator
} else if (pp > firstClosed) {
d[pos] = firstClosed;
id = st.erase(id); // xoá và cập nhật iterator
break;
} else {
s[pos] ^= 1;
++id;
}
}
}
answer(s, d);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |