Submission #1080769

#TimeUsernameProblemLanguageResultExecution timeMemory
1080769jcelinCave (IOI13_cave)C++14
100 / 100
157 ms604 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<pll> vpll;

#define PB push_back
#define PF push_front
#define PPB pop_back
#define PPF pop_front
#define X first
#define Y second
#define MP make_pair
#define all(x) (x).begin(), (x).end()

const int mod = 1e9 + 7; //998244353;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;
const int logo = 20;
const int MAXN = 5007;
const int off = 1 << logo;
const int trsz = off << 1;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

int s[MAXN], d[MAXN];

void exploreCave(int n){
	for(int i=0; i<n; i++) s[i] = 0, d[i] = -1;
	int lst = tryCombination(s);
	for(int i=0; i<n; i++){
		int lo = 0, hi = n - 1;
		while(lo < hi){
			int mid = (lo + hi) / 2;
			for(int j=lo; j<=mid; j++) if(d[j] == -1) s[j] ^= 1;
			int vl = tryCombination(s);
			if((vl != i and lst != i) or (vl == i and lst == i)) lo = mid + 1;
			else hi = mid;
			lst = vl;
		}
		d[lo] = i;
		if(lst == i) s[lo] ^= 1;
		lst = tryCombination(s);
	}
	
	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...