Submission #1036240

# Submission time Handle Problem Language Result Execution time Memory
1036240 2024-07-27T06:48:21 Z Alihan_8 The Big Prize (IOI17_prize) C++17
0 / 100
67 ms 5596 KB
#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;
}

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;
	
	map <int,int> us;
	
	for ( int i = n - 1; i >= 0; i-- ){
		auto c = f(i);
		
		int s = c[0] + c[1];
		
		if ( us.count(s) ) continue;
		
		if ( c[0] + c[1] == 0 ){
			ans = i;
		}
		
		us[s] = true;
		
		int l = 0, r = i;
		
		while ( l < r ){
			int m = (l + r) / 2;
			
			if ( f(m) != c ){
				l = m + 1;
			} else r = m;
		}
		
		i = l; 
	}
	
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 5596 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 5592 KB Incorrect
2 Halted 0 ms 0 KB -