Submission #118596

# Submission time Handle Problem Language Result Execution time Memory
118596 2019-06-19T09:34:56 Z StevenH The Big Prize (IOI17_prize) C++14
96.16 / 100
60 ms 648 KB
#include "prize.h"
#include <cstring>
//#include <bits\stdc++.h> 
using namespace std;
const int maxn = 200005;
bool vis[maxn];
int lp;
									//rx right of r
int find(int l,int r,int lx,int rx)	//lx left of l
{
	int mid,tmp,nm;
	mid=(l+r)/2;

	while(vis[mid] && mid<=r)mid++;
	if(mid>r)
	{
		mid=(l+r)/2;
		while(vis[mid] && mid>=l)mid--;
		if(mid<l)return 0;	// 0 not find any thing
	}
	
	vector<int> res = ask(mid);
	vis[mid]=true;
	
	if(mid<l || mid>199999)return 0;
	
	if(res[0]+res[1]==0)return mid;
	else if(res[0]+res[1]==lp)
	{
		if(res[0]-lx>0)	 // left not empty 
		{
			tmp=find(l,mid-1,lx,res[1]);
			if(tmp)return tmp;
		}
		if(res[1]-rx>0)	// right not empty
		{
			tmp=find(mid+1,r,res[0],rx);
			if(tmp)return tmp;
		}
	}
	else if(tmp=find(l,r,lx,rx))return tmp;
	
	return 0;
}

int find_best(int n) {
	int mx=-1,nm,id;
	//vector<int> res = ask(i);
	for(int i=0;i<476;i++)
	{
		vector<int> res = ask(i);
		int tmp = res[0] + res[1];
		if(tmp==0)
		{
			//cout<<i;
			return i;
		}
		if(tmp>mx)
		{
			mx=tmp;
			id=i;
			nm=1;
		}
		if(tmp==mx)nm++;
	}
	
	lp=mx;	//lp refers to lollipop
	memset(vis,false,sizeof(vis));
	int tp=find(476,n-1,476-nm,0);
	//cout<<tp;
	return tp;
	
	return 0;
}

Compilation message

prize.cpp: In function 'int find(int, int, int, int)':
prize.cpp:41:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  else if(tmp=find(l,r,lx,rx))return tmp;
          ~~~^~~~~~~~~~~~~~~~
prize.cpp:11:14: warning: unused variable 'nm' [-Wunused-variable]
  int mid,tmp,nm;
              ^~
prize.cpp: In function 'int find_best(int)':
prize.cpp:47:15: warning: variable 'id' set but not used [-Wunused-but-set-variable]
  int mx=-1,nm,id;
               ^~
prize.cpp:47:12: warning: 'nm' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int mx=-1,nm,id;
            ^~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 9 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 4 ms 528 KB Output is correct
5 Correct 5 ms 568 KB Output is correct
6 Correct 2 ms 400 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 3 ms 520 KB Output is correct
9 Correct 7 ms 436 KB Output is correct
10 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 7 ms 504 KB Output is correct
4 Correct 5 ms 516 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 4 ms 560 KB Output is correct
9 Correct 6 ms 440 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 9 ms 504 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 10 ms 424 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 9 ms 504 KB Output is correct
16 Correct 17 ms 512 KB Output is correct
17 Correct 3 ms 308 KB Output is correct
18 Partially correct 19 ms 516 KB Partially correct - number of queries: 5241
19 Correct 7 ms 256 KB Output is correct
20 Correct 16 ms 504 KB Output is correct
21 Correct 9 ms 520 KB Output is correct
22 Correct 6 ms 452 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 4 ms 448 KB Output is correct
25 Correct 28 ms 504 KB Output is correct
26 Correct 11 ms 512 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 25 ms 504 KB Output is correct
29 Correct 19 ms 524 KB Output is correct
30 Partially correct 20 ms 520 KB Partially correct - number of queries: 5203
31 Correct 7 ms 384 KB Output is correct
32 Correct 5 ms 520 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 25 ms 504 KB Output is correct
35 Correct 6 ms 504 KB Output is correct
36 Correct 17 ms 504 KB Output is correct
37 Correct 6 ms 376 KB Output is correct
38 Correct 6 ms 504 KB Output is correct
39 Correct 21 ms 504 KB Output is correct
40 Correct 16 ms 452 KB Output is correct
41 Correct 14 ms 504 KB Output is correct
42 Correct 30 ms 504 KB Output is correct
43 Correct 20 ms 432 KB Output is correct
44 Correct 15 ms 504 KB Output is correct
45 Correct 13 ms 504 KB Output is correct
46 Correct 3 ms 308 KB Output is correct
47 Correct 10 ms 512 KB Output is correct
48 Correct 14 ms 528 KB Output is correct
49 Correct 6 ms 504 KB Output is correct
50 Partially correct 24 ms 512 KB Partially correct - number of queries: 5238
51 Correct 29 ms 532 KB Output is correct
52 Correct 6 ms 376 KB Output is correct
53 Correct 8 ms 504 KB Output is correct
54 Correct 26 ms 376 KB Output is correct
55 Correct 3 ms 384 KB Output is correct
56 Partially correct 56 ms 376 KB Partially correct - number of queries: 5238
57 Correct 31 ms 504 KB Output is correct
58 Correct 22 ms 520 KB Output is correct
59 Correct 32 ms 444 KB Output is correct
60 Correct 12 ms 512 KB Output is correct
61 Correct 7 ms 376 KB Output is correct
62 Correct 3 ms 528 KB Output is correct
63 Correct 4 ms 640 KB Output is correct
64 Correct 4 ms 528 KB Output is correct
65 Correct 7 ms 504 KB Output is correct
66 Correct 9 ms 636 KB Output is correct
67 Correct 12 ms 552 KB Output is correct
68 Correct 5 ms 256 KB Output is correct
69 Correct 9 ms 424 KB Output is correct
70 Correct 7 ms 504 KB Output is correct
71 Partially correct 41 ms 444 KB Partially correct - number of queries: 5244
72 Correct 8 ms 384 KB Output is correct
73 Partially correct 19 ms 520 KB Partially correct - number of queries: 5181
74 Partially correct 34 ms 432 KB Partially correct - number of queries: 5208
75 Correct 9 ms 512 KB Output is correct
76 Correct 32 ms 512 KB Output is correct
77 Partially correct 48 ms 512 KB Partially correct - number of queries: 5384
78 Correct 11 ms 432 KB Output is correct
79 Correct 12 ms 648 KB Output is correct
80 Partially correct 20 ms 520 KB Partially correct - number of queries: 5351
81 Partially correct 60 ms 376 KB Partially correct - number of queries: 5346
82 Partially correct 55 ms 376 KB Partially correct - number of queries: 5310
83 Correct 7 ms 512 KB Output is correct
84 Correct 17 ms 536 KB Output is correct
85 Partially correct 24 ms 520 KB Partially correct - number of queries: 5319
86 Correct 9 ms 524 KB Output is correct
87 Correct 3 ms 540 KB Output is correct
88 Correct 3 ms 520 KB Output is correct
89 Correct 3 ms 648 KB Output is correct
90 Correct 5 ms 384 KB Output is correct
91 Correct 8 ms 384 KB Output is correct
92 Correct 7 ms 376 KB Output is correct
93 Correct 8 ms 512 KB Output is correct
94 Correct 11 ms 512 KB Output is correct
95 Correct 10 ms 512 KB Output is correct
96 Correct 6 ms 512 KB Output is correct
97 Correct 5 ms 512 KB Output is correct