Submission #117225

# Submission time Handle Problem Language Result Execution time Memory
117225 2019-06-15T11:33:29 Z tinjyu The Big Prize (IOI17_prize) C++14
97.68 / 100
64 ms 2048 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
int m,ball=0,a[200005][2],ans=-1;
int find(int x)
{
	if(a[x][0]==-1)
	{
		std::vector<int> res = ask(x);
		a[x][0]=res[0];
		a[x][1]=res[1];
	}
	return 0;
}
int solve(int s,int e){
	//cout<<s<<" "<<e<<endl;
	if(s>=e-1)return 0;
	if(ans!=-1)return 0;
	int ne,ns;
	if((s+e)%2==0)ne=(s+e)/2,ns=(s+e)/2;
	else ne=(s+e)/2+1,ns=(s+e)/2+1;
	while(ns<e)
	{
		find(ns);
		if(a[ns][0]+a[ns][1]==0)
		{
			ans=ns;
			return 0;
		}
		if(a[ns][0]+a[ns][1]!=ball)ns++;
		else break;
	}
	while(s<ne)
	{
		find(ne);
		if(a[ne][0]+a[ne][1]==0)
		{
			ans=ne;
			break;
		}
		if(a[ne][0]+a[ne][1]!=ball)ne--;
		else break;
	}
	//cout<<ne<<" "<<ns<<endl;
	if(a[s][0]!=a[ne][0] )solve(s,ne);
	if(a[ns][0]!=a[e][0] )solve(ns,e);
}
int find_best(int n) {
	for(int i=0;i<n;i++)
	{
		a[i][0]=-1;
		a[i][1]=-1;
	}
	for(int i = 0; i < 473; i++) {
		find(i);
		//cout<<a[i][0]<<" "<<a[i][1]<<endl;
		if(a[i][0]+a[i][1]==0)
		{
			ans=i;
			break;
		}
		if(a[i][0] + a[i][1] > ball)
		{
			m=i;
			ball=a[i][0]+a[i][1];
		}
	}
	if(ans!=-1)return ans;
 
//	cout<<m<<endl;
	int start=0,end=n-1;
	while(true)
	{
		find(start);
		if(a[start][0]+a[start][1]==0)ans=start;
		if(a[start][0]+a[start][1]!=ball)start++;
		else break;
	}
	while(true)
	{
		find(end);
		if(a[end][0]+a[end][1]==0)ans=end;
		if(a[end][0]+a[end][1]!=ball)end--;
		else break;
	}
	if(ans!=-1)return ans;
	//cout<<start<<" "<<end<<endl;
	solve(start,m);
	solve(m,end);
	return ans;
}

Compilation message

prize.cpp: In function 'int solve(int, int)':
prize.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1792 KB Output is correct
2 Correct 9 ms 1912 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 6 ms 1792 KB Output is correct
5 Correct 7 ms 1784 KB Output is correct
6 Correct 3 ms 1792 KB Output is correct
7 Correct 6 ms 1784 KB Output is correct
8 Correct 4 ms 1912 KB Output is correct
9 Correct 4 ms 1936 KB Output is correct
10 Correct 8 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1812 KB Output is correct
2 Correct 5 ms 1920 KB Output is correct
3 Correct 9 ms 1792 KB Output is correct
4 Correct 10 ms 1852 KB Output is correct
5 Correct 5 ms 1784 KB Output is correct
6 Correct 4 ms 1784 KB Output is correct
7 Correct 10 ms 1792 KB Output is correct
8 Correct 8 ms 1920 KB Output is correct
9 Correct 9 ms 1792 KB Output is correct
10 Correct 8 ms 1792 KB Output is correct
11 Correct 7 ms 1784 KB Output is correct
12 Correct 4 ms 1932 KB Output is correct
13 Correct 13 ms 1792 KB Output is correct
14 Correct 9 ms 384 KB Output is correct
15 Correct 7 ms 1912 KB Output is correct
16 Correct 33 ms 1912 KB Output is correct
17 Correct 4 ms 1912 KB Output is correct
18 Partially correct 27 ms 1920 KB Partially correct - number of queries: 5093
19 Correct 5 ms 1792 KB Output is correct
20 Correct 13 ms 1152 KB Output is correct
21 Correct 19 ms 1792 KB Output is correct
22 Correct 6 ms 1912 KB Output is correct
23 Correct 5 ms 1848 KB Output is correct
24 Correct 9 ms 1784 KB Output is correct
25 Correct 13 ms 1920 KB Output is correct
26 Correct 20 ms 1784 KB Output is correct
27 Correct 8 ms 1784 KB Output is correct
28 Correct 46 ms 1784 KB Output is correct
29 Correct 24 ms 1784 KB Output is correct
30 Partially correct 34 ms 1848 KB Partially correct - number of queries: 5040
31 Correct 6 ms 1856 KB Output is correct
32 Correct 12 ms 1792 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 15 ms 1784 KB Output is correct
35 Correct 5 ms 2040 KB Output is correct
36 Correct 16 ms 1784 KB Output is correct
37 Correct 9 ms 1912 KB Output is correct
38 Correct 9 ms 1920 KB Output is correct
39 Correct 11 ms 1852 KB Output is correct
40 Correct 27 ms 1792 KB Output is correct
41 Correct 29 ms 1784 KB Output is correct
42 Correct 14 ms 2048 KB Output is correct
43 Correct 26 ms 1864 KB Output is correct
44 Correct 18 ms 1792 KB Output is correct
45 Correct 19 ms 1832 KB Output is correct
46 Correct 5 ms 2040 KB Output is correct
47 Correct 12 ms 1920 KB Output is correct
48 Correct 40 ms 1784 KB Output is correct
49 Correct 11 ms 1784 KB Output is correct
50 Partially correct 33 ms 1784 KB Partially correct - number of queries: 5073
51 Correct 22 ms 1784 KB Output is correct
52 Correct 5 ms 1912 KB Output is correct
53 Correct 8 ms 1784 KB Output is correct
54 Correct 18 ms 1784 KB Output is correct
55 Correct 8 ms 1852 KB Output is correct
56 Partially correct 55 ms 1784 KB Partially correct - number of queries: 5105
57 Correct 27 ms 1784 KB Output is correct
58 Correct 37 ms 1784 KB Output is correct
59 Correct 25 ms 1844 KB Output is correct
60 Correct 25 ms 1784 KB Output is correct
61 Correct 8 ms 1792 KB Output is correct
62 Correct 8 ms 1792 KB Output is correct
63 Correct 9 ms 1812 KB Output is correct
64 Correct 5 ms 2048 KB Output is correct
65 Correct 5 ms 1784 KB Output is correct
66 Correct 13 ms 1912 KB Output is correct
67 Correct 11 ms 1792 KB Output is correct
68 Correct 6 ms 1784 KB Output is correct
69 Correct 9 ms 1784 KB Output is correct
70 Correct 6 ms 1912 KB Output is correct
71 Partially correct 52 ms 1792 KB Partially correct - number of queries: 5232
72 Correct 11 ms 1792 KB Output is correct
73 Partially correct 40 ms 1792 KB Partially correct - number of queries: 5169
74 Partially correct 63 ms 1792 KB Partially correct - number of queries: 5196
75 Correct 9 ms 1792 KB Output is correct
76 Correct 48 ms 1792 KB Output is correct
77 Partially correct 42 ms 1856 KB Partially correct - number of queries: 5213
78 Correct 14 ms 1792 KB Output is correct
79 Correct 13 ms 1792 KB Output is correct
80 Partially correct 32 ms 1792 KB Partially correct - number of queries: 5225
81 Partially correct 64 ms 1820 KB Partially correct - number of queries: 5177
82 Partially correct 62 ms 1792 KB Partially correct - number of queries: 5133
83 Correct 6 ms 1856 KB Output is correct
84 Correct 17 ms 1940 KB Output is correct
85 Partially correct 52 ms 1792 KB Partially correct - number of queries: 5168
86 Correct 8 ms 1792 KB Output is correct
87 Correct 10 ms 1792 KB Output is correct
88 Correct 6 ms 2048 KB Output is correct
89 Correct 9 ms 1792 KB Output is correct
90 Correct 7 ms 1920 KB Output is correct
91 Correct 5 ms 2048 KB Output is correct
92 Correct 5 ms 2048 KB Output is correct
93 Correct 9 ms 1792 KB Output is correct
94 Correct 8 ms 1792 KB Output is correct
95 Correct 8 ms 1920 KB Output is correct
96 Correct 5 ms 1920 KB Output is correct
97 Correct 7 ms 1792 KB Output is correct