Submission #1036258

#TimeUsernameProblemLanguageResultExecution timeMemory
1036258Alihan_8The Big Prize (IOI17_prize)C++17
20 / 100
39 ms5524 KiB
#include "prize.h"

#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
//#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}


mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng)

int find_best(int n){
	vector <vector<int>> dp(n);
	
	auto f = [&](int j){
		if ( dp[j].empty() ){
			dp[j] = ask(j);
		}
		
		return dp[j];
	};
	
	int ans = -1;
	
	auto dnc = [&](auto dnc, int l, int r) -> void{
		if ( l > r ) return;
		
		int m = (l + r) / 2;
		
		auto c = f(m);
		
		if ( c[0] + c[1] == 0 ){
			ans = m;
		}
		
		int p = m, q = r + 1;
		
		while ( p + 1 < q ){
			int md = (p + q) / 2;
			
			if ( f(md) != c ){
				q = md;
			} else p = md;
		}
		
		dnc(dnc, l, m - 1), dnc(dnc, p + 1, r);
	};
	
	dnc(dnc, 0, n - 1);
	
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...