Submission #891313

#TimeUsernameProblemLanguageResultExecution timeMemory
891313oblantisCave (IOI13_cave)C++17
100 / 100
191 ms856 KiB
#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 exploreCave(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 = tryCombination(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 = tryCombination(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);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...