Submission #1080784

#TimeUsernameProblemLanguageResultExecution timeMemory
1080784TobCave (IOI13_cave)C++14
100 / 100
381 ms820 KiB
#include <bits/stdc++.h>

#include "cave.h"

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

int c[5000], bio[5000], res[5000], sta[5000];

void exploreCave(int n) {
	for (int i = 0; i < n; i++) {
		int lo = 0, hi = n-1;
		memset(c, 0, sizeof c);
		for (int j = 0; j < n; j++) c[j] = (bio[j] ? sta[j] : 0);
		int x = tryCombination(c);
		while (lo < hi) {
			int mid = (lo + hi) / 2;
			memset(c, 0, sizeof c);
			for (int j = 0; j < n; j++) c[j] = (bio[j] ? sta[j] : (j <= mid));
			int y = tryCombination(c);
			if ((x == i && y != i) || (x != i && y == i)) hi = mid;
			else lo = mid+1;
		}
		sta[lo] = (x == i);
		res[lo] = i;
		bio[lo] = 1;
	}
	answer(sta, res);
}
#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...