Submission #103100

# Submission time Handle Problem Language Result Execution time Memory
103100 2019-03-29T03:16:36 Z username The Big Prize (IOI17_prize) C++14
100 / 100
46 ms 768 KB
#include<bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
#define F first
#define S second
#define de(...) cerr<<__VA_ARGS__
#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
 
map<int,pii>mp;
pii qr(int i){
	if(mp.count(i))return mp[i];
	else{
		VI tt=ask(i);
		return mp[i]=pii(tt[0],tt[1]);
	}
}

void dfs(int l,int r,pii ll,pii rr,int mx,int&res){
	if(res>=0)return;
	else if(l+1<r&&ll==rr)return;
	else{
		pii tt=qr(mid);
		if(tt.F+tt.S==0)res=mid;
		if(l+1<r){
			if(tt.F+tt.S!=mx){
				if(l<mid&&ll!=tt)dfs(l,mid,ll,qr(mid-1),mx,res);
				if(mid+1<r&&tt!=rr)dfs(mid+1,r,qr(mid+1),rr,mx,res);
			}else{
				dfs(l,mid,ll,tt,mx,res);
				dfs(mid,r,tt,rr,mx,res);
			}
		}
	}
}
 
int find_best(int n){
	int res=-1,mx=0;
	REP(i,0,min(n,10)){
		pii tt=qr(i);
		mx=max(mx,tt.F+tt.S);
	}
	dfs(0,n,qr(0),pii(mx,0),mx,res);
	return res;
}

Compilation message

prize.cpp: In function 'void dfs(int, int, pii, pii, int, int&)':
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:32:13: note: in expansion of macro 'mid'
   pii tt=qr(mid);
             ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:33:23: note: in expansion of macro 'mid'
   if(tt.F+tt.S==0)res=mid;
                       ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:36:10: note: in expansion of macro 'mid'
     if(l<mid&&ll!=tt)dfs(l,mid,ll,qr(mid-1),mx,res);
          ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:36:28: note: in expansion of macro 'mid'
     if(l<mid&&ll!=tt)dfs(l,mid,ll,qr(mid-1),mx,res);
                            ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:36:38: note: in expansion of macro 'mid'
     if(l<mid&&ll!=tt)dfs(l,mid,ll,qr(mid-1),mx,res);
                                      ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:37:8: note: in expansion of macro 'mid'
     if(mid+1<r&&tt!=rr)dfs(mid+1,r,qr(mid+1),rr,mx,res);
        ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:37:28: note: in expansion of macro 'mid'
     if(mid+1<r&&tt!=rr)dfs(mid+1,r,qr(mid+1),rr,mx,res);
                            ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:37:39: note: in expansion of macro 'mid'
     if(mid+1<r&&tt!=rr)dfs(mid+1,r,qr(mid+1),rr,mx,res);
                                       ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:39:11: note: in expansion of macro 'mid'
     dfs(l,mid,ll,tt,mx,res);
           ^~~
prize.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define mid (l+r>>1)
              ~^~
prize.cpp:40:9: note: in expansion of macro 'mid'
     dfs(mid,r,tt,rr,mx,res);
         ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 428 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 308 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 304 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 304 KB Output is correct
8 Correct 2 ms 388 KB Output is correct
9 Correct 2 ms 316 KB Output is correct
10 Correct 2 ms 304 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 2 ms 308 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 348 KB Output is correct
16 Correct 40 ms 452 KB Output is correct
17 Correct 2 ms 308 KB Output is correct
18 Correct 24 ms 596 KB Output is correct
19 Correct 2 ms 312 KB Output is correct
20 Correct 10 ms 312 KB Output is correct
21 Correct 13 ms 376 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 312 KB Output is correct
25 Correct 23 ms 452 KB Output is correct
26 Correct 22 ms 376 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 29 ms 492 KB Output is correct
29 Correct 23 ms 488 KB Output is correct
30 Correct 38 ms 576 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 5 ms 304 KB Output is correct
33 Correct 3 ms 256 KB Output is correct
34 Correct 15 ms 384 KB Output is correct
35 Correct 4 ms 256 KB Output is correct
36 Correct 12 ms 376 KB Output is correct
37 Correct 3 ms 304 KB Output is correct
38 Correct 2 ms 256 KB Output is correct
39 Correct 17 ms 504 KB Output is correct
40 Correct 36 ms 504 KB Output is correct
41 Correct 27 ms 416 KB Output is correct
42 Correct 18 ms 464 KB Output is correct
43 Correct 21 ms 424 KB Output is correct
44 Correct 14 ms 408 KB Output is correct
45 Correct 13 ms 508 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 22 ms 376 KB Output is correct
48 Correct 32 ms 412 KB Output is correct
49 Correct 6 ms 312 KB Output is correct
50 Correct 34 ms 504 KB Output is correct
51 Correct 15 ms 428 KB Output is correct
52 Correct 2 ms 400 KB Output is correct
53 Correct 2 ms 524 KB Output is correct
54 Correct 20 ms 496 KB Output is correct
55 Correct 3 ms 256 KB Output is correct
56 Correct 41 ms 504 KB Output is correct
57 Correct 24 ms 504 KB Output is correct
58 Correct 15 ms 580 KB Output is correct
59 Correct 19 ms 504 KB Output is correct
60 Correct 20 ms 376 KB Output is correct
61 Correct 4 ms 256 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 4 ms 256 KB Output is correct
64 Correct 4 ms 376 KB Output is correct
65 Correct 3 ms 384 KB Output is correct
66 Correct 3 ms 256 KB Output is correct
67 Correct 3 ms 256 KB Output is correct
68 Correct 2 ms 520 KB Output is correct
69 Correct 4 ms 256 KB Output is correct
70 Correct 3 ms 256 KB Output is correct
71 Correct 43 ms 552 KB Output is correct
72 Correct 4 ms 436 KB Output is correct
73 Correct 42 ms 528 KB Output is correct
74 Correct 25 ms 720 KB Output is correct
75 Correct 4 ms 256 KB Output is correct
76 Correct 40 ms 516 KB Output is correct
77 Correct 23 ms 652 KB Output is correct
78 Correct 9 ms 384 KB Output is correct
79 Correct 12 ms 528 KB Output is correct
80 Correct 46 ms 540 KB Output is correct
81 Correct 40 ms 504 KB Output is correct
82 Correct 42 ms 544 KB Output is correct
83 Correct 2 ms 384 KB Output is correct
84 Correct 27 ms 504 KB Output is correct
85 Correct 32 ms 768 KB Output is correct
86 Correct 13 ms 336 KB Output is correct
87 Correct 6 ms 256 KB Output is correct
88 Correct 8 ms 256 KB Output is correct
89 Correct 6 ms 424 KB Output is correct
90 Correct 3 ms 256 KB Output is correct
91 Correct 9 ms 256 KB Output is correct
92 Correct 3 ms 256 KB Output is correct
93 Correct 5 ms 256 KB Output is correct
94 Correct 8 ms 412 KB Output is correct
95 Correct 5 ms 452 KB Output is correct
96 Correct 5 ms 256 KB Output is correct
97 Correct 2 ms 256 KB Output is correct