#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pr pair<int, int>
#define tri array<int, 3>
const int INF = 1e9 + 7;
int n;
void exploreCave(int N) {
n = N;
int pos[n], color[n], cur[n];
for (int i = 0; i < n; i++) {
pos[i] = 0; color[i] = 0; cur[i] = 0;
}
vector<bool> found(n, 0);
for (int i = 0; i < n; i++) {
int c;
int ttt = tryCombination(cur);
if (ttt > i || ttt == -1) c = 0;
else c = 1;
color[i] = c;
vector<int> idk;
for (int j = 0; j < n; j++) {
if (found[j]) idk.pb(j);
}
int l = 0, r = idk.size(), m;
while (l + 1 < r) {
m = (l + r) / 2;
int temp[n];
for (int j = 0; j < n; j++) {
temp[j] = cur[j];
}
for (int j = l; j < m; j++) {
temp[idk[j]] = c;
}
int t = tryCombination(temp);
if (t > i || t == -1) r = m;
else l = m;
}
found[l] = 1;
pos[l] = i;
cur[l] = c;
}
answer(color, pos);
}
| # | 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... |