| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1307843 | ayaz | Cave (IOI13_cave) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "cave.h"
#include "grader.c"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define isz(x) int(x.size())
using vi = vector<int>;
using ll = long long;
using pii = pair<int, int>;
const int inf = 1e9;
void exploreCave(int N) {
int n = N;
int s[n], d[n];
fill(s, s + n, 1);
fill(d, d + n, inf);
for (int _ = 1; _ <= n; _++) {
if (tryCombination(s) == -1) {
break;
}
int idx = tryCombination(s);
for (int i = 0; i < n; i++) {
if (s[i] == 0) continue;
s[i] = 0;
int cur = tryCombination(s);
if (cur == -1 || cur > idx) {
d[i] = idx;
break;
}
s[i] = 1;
}
}
fill(s, s + n, 0);
for (int _ = 1; _ <= n; _++) {
if (tryCombination(s) == -1) {
break;
}
int idx = tryCombination(s);
for (int i = 0; i < n; i++) {
if (s[i] == 1) continue;
s[i] = 1;
int cur = tryCombination(s);
if (cur > idx) {
d[i] = idx;
break;
}
s[i] = 0;
}
}
answer(s, d);
}
