#include "cave.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
void exploreCave(int N) {
int n = N, i, j;
int isfound[n], f[n], sw[n], fa[n];
for(i = 0; i < n; i++)
{
f[i] = 0;
isfound[i] = 0;
sw[i] = 0;
}
for(i = 0; i < n; i++)
{
int ask = tryCombination(f);
for(j = 0; j < n; j++)
fa[j] = f[j];
int l = 0, r = n - 1;
while(l <= r)
{
int mid = (l + r) / 2;
for(j = l; j <= mid; j++)
{
if(!isfound[j])
fa[j] = 1 - fa[j];
}
int res = tryCombination(fa);
int p1 = (ask == i), p2 = (res == i);
if(p1 != p2)
r = (l + r) / 2 - 1;
else
l = (l + r) / 2 + 1;
}
isfound[l] = 1;
sw[l] = i;
if(ask == i)
fa[l] = 1 - fa[l];
for(j = 0; j < n; j++)
f[j] = fa[j];
}
answer(f, sw);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
348 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
576 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
348 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |