# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891309 | oblantis | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "cave.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
const int inf = 1e9 + 10000;
const int mod = 1e9+7;
const int maxn = 5000 + 12;
void explore_Cave(int n){
int s[n], d[n];
for(int i = 0; i < n; i++)s[i] = 0, d[i] = -1;
int nd = n;
int x = 0;
while(nd){
int wt = try_combination(s);
vi dk;
for(int j = 0; j < n; j++){
if(d[j] == -1){
if(wt == x)s[j] ^= 1;
dk.pb(j);
}
}
int l = 0, r = dk.size();
while(l + 1 < r){
int mid = l + (r - l) / 2;
for(int i = l; i < mid; i++){
s[dk[i]] ^= 1;
}
wt = try_combination(s);
for(int i = l; i < mid; i++)s[dk[i]] ^= 1;
if(wt == x)r = mid;
else l = mid;
}
d[dk[l]] = x;
nd--;
x++;
}
answer(s, d);
}