Submission #933678

# Submission time Handle Problem Language Result Execution time Memory
933678 2024-02-26T05:02:11 Z thunopro The Big Prize (IOI17_prize) C++14
100 / 100
29 ms 6200 KB
#include<bits/stdc++.h>
using namespace std ; 
#define maxn 200009
#define ll long long 
#define pb push_back 
#define fi first 
#define se second 
#define left id<<1
#define right id<<1|1 
#define re exit(0); 
#define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin()+1
const int mod = 1e9+7 ;
const int INF = 1e9 ; 

typedef vector<int> vi ; 
typedef pair<int,int> pii ; 
typedef vector<pii> vii ; 

template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; } 
template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; } 

void add ( int &a , int b ) 
{
	a += b ; 
	if ( a >= mod ) a -= mod ; 
	if ( a < 0 ) a += mod ; 
}

void rf () 
{
	freopen ("bai1.inp","r",stdin) ;
}

int _pow ( int a , int n ) 
{
	if ( n == 0 ) return 1 ; 
	int res = _pow (a,n/2) ; 
	if ( n % 2 ) return 1ll*res*res%mod*a%mod ; 
	else return 1ll*res*res%mod ; 
}

//int main () 
//{
//	ios_base::sync_with_stdio(0); 
//	cin.tie(0);cout.tie(0); 
////	rf () ; 
//}

vi ask ( int i ) ; 

int res = -1 , mx = -1 ; 
vi asked [maxn] ; 
vi Ask ( int i ) 
{
	if ( asked[i].empty() ) asked [i] = ask (i) ; 
	chkmax (mx,asked[i][0]+asked[i][1]) ; 
	return asked [i] ; 
}
int Ask_cnt ( int i ) 
{
	vi v = Ask (i) ; 
	if ( v [0] + v [1] == 0 ) res = i ; 
	return v [0] + v [1] ; 
}
void solve ( int l , int r ) 
{
	while ( Ask_cnt (l) != mx && l <= r ) l ++ ; 
	while ( Ask_cnt (r) != mx && l <= r ) r -- ; 
	if ( res != -1 ) return ; 
	if ( l >= r ) return ; 
	vi A = Ask (l) , B = Ask (r) ; 
	if ( A [0] == B [0] && A [1] == B [1] ) return ; 
	int mid = (l+r)/2 ; 
	solve (l,mid) ; 
	solve (mid,r) ; 
}

int find_best ( int n ) 
{
	solve (0,n-1) ; 
	return res ; 
}

Compilation message

prize.cpp: In function 'void rf()':
prize.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  freopen ("bai1.inp","r",stdin) ;
      |  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 2 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 1 ms 5208 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 1 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 5204 KB Output is correct
11 Correct 2 ms 5140 KB Output is correct
12 Correct 1 ms 4952 KB Output is correct
13 Correct 3 ms 5400 KB Output is correct
14 Correct 2 ms 5388 KB Output is correct
15 Correct 5 ms 5400 KB Output is correct
16 Correct 19 ms 5976 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 20 ms 5452 KB Output is correct
19 Correct 1 ms 4952 KB Output is correct
20 Correct 7 ms 5904 KB Output is correct
21 Correct 10 ms 5232 KB Output is correct
22 Correct 3 ms 5392 KB Output is correct
23 Correct 1 ms 4952 KB Output is correct
24 Correct 1 ms 4952 KB Output is correct
25 Correct 11 ms 5948 KB Output is correct
26 Correct 14 ms 5412 KB Output is correct
27 Correct 1 ms 5132 KB Output is correct
28 Correct 19 ms 5696 KB Output is correct
29 Correct 18 ms 5404 KB Output is correct
30 Correct 26 ms 5420 KB Output is correct
31 Correct 1 ms 4952 KB Output is correct
32 Correct 2 ms 5396 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Correct 9 ms 5400 KB Output is correct
35 Correct 2 ms 5132 KB Output is correct
36 Correct 7 ms 5388 KB Output is correct
37 Correct 2 ms 5132 KB Output is correct
38 Correct 1 ms 4952 KB Output is correct
39 Correct 13 ms 5408 KB Output is correct
40 Correct 24 ms 5668 KB Output is correct
41 Correct 15 ms 5956 KB Output is correct
42 Correct 16 ms 5696 KB Output is correct
43 Correct 12 ms 5928 KB Output is correct
44 Correct 8 ms 5924 KB Output is correct
45 Correct 8 ms 5900 KB Output is correct
46 Correct 1 ms 4948 KB Output is correct
47 Correct 11 ms 5680 KB Output is correct
48 Correct 20 ms 5500 KB Output is correct
49 Correct 3 ms 5140 KB Output is correct
50 Correct 29 ms 5484 KB Output is correct
51 Correct 9 ms 5668 KB Output is correct
52 Correct 2 ms 5208 KB Output is correct
53 Correct 2 ms 5136 KB Output is correct
54 Correct 9 ms 5424 KB Output is correct
55 Correct 1 ms 4952 KB Output is correct
56 Correct 21 ms 5964 KB Output is correct
57 Correct 18 ms 5696 KB Output is correct
58 Correct 16 ms 5952 KB Output is correct
59 Correct 13 ms 5144 KB Output is correct
60 Correct 13 ms 5456 KB Output is correct
61 Correct 2 ms 5140 KB Output is correct
62 Correct 1 ms 4952 KB Output is correct
63 Correct 2 ms 5132 KB Output is correct
64 Correct 2 ms 5132 KB Output is correct
65 Correct 1 ms 4952 KB Output is correct
66 Correct 3 ms 5140 KB Output is correct
67 Correct 3 ms 5140 KB Output is correct
68 Correct 3 ms 5144 KB Output is correct
69 Correct 3 ms 5144 KB Output is correct
70 Correct 3 ms 5396 KB Output is correct
71 Correct 20 ms 5928 KB Output is correct
72 Correct 3 ms 5144 KB Output is correct
73 Correct 23 ms 5504 KB Output is correct
74 Correct 28 ms 5740 KB Output is correct
75 Correct 2 ms 5136 KB Output is correct
76 Correct 22 ms 5992 KB Output is correct
77 Correct 23 ms 5640 KB Output is correct
78 Correct 3 ms 5392 KB Output is correct
79 Correct 10 ms 5924 KB Output is correct
80 Correct 25 ms 5892 KB Output is correct
81 Correct 24 ms 6160 KB Output is correct
82 Correct 25 ms 6156 KB Output is correct
83 Correct 2 ms 5136 KB Output is correct
84 Correct 18 ms 5924 KB Output is correct
85 Correct 23 ms 6200 KB Output is correct
86 Correct 3 ms 5388 KB Output is correct
87 Correct 1 ms 5132 KB Output is correct
88 Correct 3 ms 5388 KB Output is correct
89 Correct 3 ms 5388 KB Output is correct
90 Correct 1 ms 5128 KB Output is correct
91 Correct 2 ms 5132 KB Output is correct
92 Correct 1 ms 4952 KB Output is correct
93 Correct 2 ms 5388 KB Output is correct
94 Correct 2 ms 5392 KB Output is correct
95 Correct 3 ms 5144 KB Output is correct
96 Correct 2 ms 5388 KB Output is correct
97 Correct 1 ms 4952 KB Output is correct