Submission #1036251

# Submission time Handle Problem Language Result Execution time Memory
1036251 2024-07-27T07:08:59 Z Alihan_8 The Big Prize (IOI17_prize) C++17
20 / 100
81 ms 5604 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;
}


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;
	
	int K = rnd(0, n - 1);
	
	for ( int i = n - 1; i > K; i-- ){
		auto c = f(i);
		
		if ( c[0] + c[1] == 0 ){
			ans = i;
			
			return ans;
		}
		
		int l = K + 1, r = i;
		
		while ( l < r ){
			int m = (l + r) / 2;
			
			if ( f(m) != c ){
				l = m + 1;
			} else r = m;
		}
		
		i = l; 
	}
	
	for ( int i = 0; i <= K; i++ ){
		auto c = f(i);
		
		if ( c[0] + c[1] == 0 ){
			ans = i;
			
			return ans;
		}
		
		int l = i, r = K + 1;
		
		while ( l + 1 < r ){
			int m = (l + r) / 2;
			
			if ( f(m) != c ){
				r = m;
			} else l = m;
		}
		
		i = l; 
	}
	
	assert(false);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 3 ms 4952 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 2 ms 5040 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 3 ms 4952 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 2 ms 4952 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 5 ms 4952 KB Output is correct
12 Correct 4 ms 4952 KB Output is correct
13 Correct 2 ms 4952 KB Output is correct
14 Correct 13 ms 1112 KB Output is correct
15 Partially correct 38 ms 5208 KB Partially correct - number of queries: 7825
16 Correct 12 ms 5208 KB Output is correct
17 Partially correct 58 ms 5604 KB Partially correct - number of queries: 9501
18 Correct 2 ms 4952 KB Output is correct
19 Correct 8 ms 4948 KB Output is correct
20 Partially correct 22 ms 2904 KB Partially correct - number of queries: 5539
21 Partially correct 29 ms 5208 KB Partially correct - number of queries: 6658
22 Correct 17 ms 5192 KB Output is correct
23 Correct 4 ms 4952 KB Output is correct
24 Correct 4 ms 4952 KB Output is correct
25 Partially correct 30 ms 5208 KB Partially correct - number of queries: 5716
26 Partially correct 54 ms 5456 KB Partially correct - number of queries: 8793
27 Correct 3 ms 4952 KB Output is correct
28 Correct 5 ms 4952 KB Output is correct
29 Correct 10 ms 5412 KB Output is correct
30 Correct 2 ms 4952 KB Output is correct
31 Correct 19 ms 5208 KB Output is correct
32 Correct 3 ms 4952 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Partially correct 33 ms 5248 KB Partially correct - number of queries: 6778
35 Correct 3 ms 4952 KB Output is correct
36 Partially correct 81 ms 5340 KB Partially correct - number of queries: 9821
37 Correct 6 ms 4952 KB Output is correct
38 Correct 2 ms 4952 KB Output is correct
39 Partially correct 50 ms 5444 KB Partially correct - number of queries: 7623
40 Correct 2 ms 4952 KB Output is correct
41 Incorrect 55 ms 5208 KB Incorrect
42 Halted 0 ms 0 KB -