Submission #1144799

#TimeUsernameProblemLanguageResultExecution timeMemory
1144799zhasynCave (IOI13_cave)C++20
0 / 100
174 ms532 KiB
#include "cave.h"
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 5 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18;
const ll mod = 1e9 + 7;

bool was[N];
void exploreCave(int n) {
	int ans[n], d[n], need, cur[n], res;
	for(int i = 0; i < n; i++){
		ans[i] = 0;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cur[j] = ans[j];
		}
		res = tryCombination(cur);
		if(res == i) need = 1;
		else need = 0;
		
		int l = 0, r = n;
		while(r - l > 1){
			int mid = r + l;
			for(int j = mid; j < r; j++){
				if(was[j]) continue;
				cur[j] = 1;
			}
			res = tryCombination(cur);
			for(int j = mid; j < r; j++){
				if(was[j]) continue;
				cur[j] = 0;
			}
			if(res != i){
				if(need == 1) l = mid;
				else r = mid;
			} else{
				if(need == 1) r = mid;
				else l = mid;
			}
		}
		was[l] = true;
		ans[l] = need;
		d[i] = l;
	}
	answer(ans, d);
}

// int main() {
  // ios::sync_with_stdio(false);
  // cin.tie(NULL);
//   
  // return 0;
// }
#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...