Submission #593764

# Submission time Handle Problem Language Result Execution time Memory
593764 2022-07-11T14:52:43 Z yutabi The Big Prize (IOI17_prize) C++14
90 / 100
59 ms 336 KB
#include "prize.h"


#include <bits/stdc++.h>
using namespace std;


#define pb push_back


vector <bool> arr1_bad(200007,0);

vector <bool> arr2_bad(600,0);



int N;

int heavy1;
int heavy2;

int query1(int loc)
{
	//printf("1 %d",loc);

	loc++;

	int l=0;
	int r=N-1;

	int m=(l+r)/2;

	int left=0;

	while(l!=r)
	{
		while(arr1_bad[m]==1 && m>l)
		{
			m--;
		}

		if(m==l && arr1_bad[m]==1)
		{
			m=(l+r)/2;

			if(left+m-l+1>=loc)
			{
				//printf(" %d\n",l+loc-left-1);

				return l+loc-left-1;
			}

			left+=m-l+1;
			l=m+1;

			m=(l+r)/2;

			continue;
		}

		vector <int> res=ask(m);

		if(res[0]+res[1]<heavy1)
		{
			arr1_bad[m]=1;

			continue;
		}

		if(res[0]<loc)
		{
			l=m+1;

			left=res[0];
		}

		else
		{
			r=m;
		}


		m=(l+r)/2;
	}

	//printf(" %d\n",l);

	return l;
}

int query2(int loc)
{
	//printf("2 %d",loc);

	loc++;

	int l=0;
	int r=heavy1-1;

	int m=(l+r)/2;

	int left=0;

	while(l!=r)
	{
		while(arr2_bad[m]==1 && m>l)
		{
			m--;
		}

		if(m==l && arr2_bad[m]==1)
		{
			m=(l+r)/2;

			if(left+m-l+1>=loc)
			{
				//printf(" %d\n",l+loc-left-1);

				return l+loc-left-1;
			}

			left+=m-l+1;
			l=m+1;

			m=(l+r)/2;

			continue;
		}

		vector <int> res=ask(query1(m));

		if(res[0]+res[1]<heavy2)
		{
			arr2_bad[m]=1;

			continue;
		}

		if(res[0]<loc)
		{
			l=m+1;

			left=res[0];
		}

		else
		{
			r=m;
		}


		m=(l+r)/2;
	}

	//printf(" %d\n",l);

	return l;
}



int find_best(int n)
{
	N=n;
	for(int i=0;i<min(600,n);i++)
	{
		vector <int> res=ask(i);

		heavy1=max(heavy1,res[0]+res[1]);
	}

	if(heavy1==1)
	{
		int l=0;
		int r=n-1;
		int m=(l+r)/2;

		while(l!=r)
		{
			vector <int> res=ask(m);

			if(res[1]==0)
			{
				r=m;
			}

			else
			{
				l=m+1;
			}

			m=(l+r)/2;
		}

		return m;
	}

	for(int i=0;i<min(30,heavy1);i++)
	{
		vector <int> res=ask(query1(i));

		heavy2=max(heavy2,res[0]+res[1]);
	}

	for(int i=0;1;i++)
	{
		vector <int> res=ask(query1(query2(i)));

		if(res[0]+res[1]==0)
		{
			return query1(query2(i));
		}
	}


	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 316 KB Output is correct
2 Correct 3 ms 320 KB Output is correct
3 Correct 3 ms 312 KB Output is correct
4 Correct 3 ms 316 KB Output is correct
5 Correct 6 ms 312 KB Output is correct
6 Correct 7 ms 320 KB Output is correct
7 Correct 6 ms 316 KB Output is correct
8 Correct 3 ms 316 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 6 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 6 ms 312 KB Output is correct
3 Correct 4 ms 312 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 7 ms 312 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 5 ms 296 KB Output is correct
9 Correct 3 ms 320 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 17 ms 208 KB Output is correct
12 Correct 12 ms 208 KB Output is correct
13 Correct 21 ms 208 KB Output is correct
14 Correct 12 ms 208 KB Output is correct
15 Correct 20 ms 208 KB Output is correct
16 Partially correct 37 ms 208 KB Partially correct - number of queries: 5227
17 Correct 12 ms 316 KB Output is correct
18 Partially correct 23 ms 320 KB Partially correct - number of queries: 6223
19 Correct 19 ms 312 KB Output is correct
20 Correct 14 ms 320 KB Output is correct
21 Correct 23 ms 316 KB Output is correct
22 Correct 16 ms 208 KB Output is correct
23 Correct 10 ms 208 KB Output is correct
24 Correct 14 ms 208 KB Output is correct
25 Correct 40 ms 316 KB Output is correct
26 Correct 32 ms 208 KB Output is correct
27 Correct 6 ms 316 KB Output is correct
28 Partially correct 43 ms 308 KB Partially correct - number of queries: 5292
29 Correct 44 ms 208 KB Output is correct
30 Partially correct 53 ms 208 KB Partially correct - number of queries: 5444
31 Correct 13 ms 208 KB Output is correct
32 Correct 14 ms 208 KB Output is correct
33 Correct 2 ms 208 KB Output is correct
34 Correct 14 ms 296 KB Output is correct
35 Correct 9 ms 300 KB Output is correct
36 Correct 15 ms 312 KB Output is correct
37 Correct 6 ms 312 KB Output is correct
38 Correct 5 ms 304 KB Output is correct
39 Correct 35 ms 296 KB Output is correct
40 Correct 23 ms 208 KB Output is correct
41 Correct 34 ms 320 KB Output is correct
42 Correct 51 ms 208 KB Output is correct
43 Correct 33 ms 300 KB Output is correct
44 Correct 32 ms 208 KB Output is correct
45 Correct 30 ms 312 KB Output is correct
46 Correct 6 ms 336 KB Output is correct
47 Correct 38 ms 208 KB Output is correct
48 Partially correct 38 ms 208 KB Partially correct - number of queries: 5092
49 Correct 13 ms 208 KB Output is correct
50 Partially correct 38 ms 316 KB Partially correct - number of queries: 6242
51 Correct 42 ms 208 KB Output is correct
52 Correct 15 ms 208 KB Output is correct
53 Correct 8 ms 312 KB Output is correct
54 Correct 14 ms 320 KB Output is correct
55 Correct 19 ms 336 KB Output is correct
56 Partially correct 24 ms 308 KB Partially correct - number of queries: 6226
57 Correct 35 ms 316 KB Output is correct
58 Correct 27 ms 312 KB Output is correct
59 Correct 28 ms 316 KB Output is correct
60 Correct 36 ms 208 KB Output is correct
61 Correct 9 ms 312 KB Output is correct
62 Correct 8 ms 208 KB Output is correct
63 Correct 7 ms 292 KB Output is correct
64 Correct 4 ms 292 KB Output is correct
65 Correct 14 ms 208 KB Output is correct
66 Correct 22 ms 312 KB Output is correct
67 Correct 14 ms 208 KB Output is correct
68 Correct 11 ms 316 KB Output is correct
69 Correct 19 ms 208 KB Output is correct
70 Correct 18 ms 300 KB Output is correct
71 Partially correct 59 ms 208 KB Partially correct - number of queries: 6125
72 Correct 13 ms 208 KB Output is correct
73 Partially correct 30 ms 208 KB Partially correct - number of queries: 5573
74 Partially correct 44 ms 208 KB Partially correct - number of queries: 5389
75 Correct 11 ms 208 KB Output is correct
76 Correct 34 ms 208 KB Output is correct
77 Partially correct 52 ms 208 KB Partially correct - number of queries: 6342
78 Correct 22 ms 208 KB Output is correct
79 Correct 31 ms 316 KB Output is correct
80 Partially correct 54 ms 208 KB Partially correct - number of queries: 6442
81 Partially correct 28 ms 336 KB Partially correct - number of queries: 6343
82 Partially correct 47 ms 208 KB Partially correct - number of queries: 5548
83 Correct 4 ms 336 KB Output is correct
84 Partially correct 49 ms 208 KB Partially correct - number of queries: 5084
85 Partially correct 51 ms 208 KB Partially correct - number of queries: 6276
86 Correct 24 ms 208 KB Output is correct
87 Correct 16 ms 208 KB Output is correct
88 Correct 30 ms 208 KB Output is correct
89 Correct 33 ms 208 KB Output is correct
90 Correct 7 ms 208 KB Output is correct
91 Correct 19 ms 208 KB Output is correct
92 Correct 15 ms 316 KB Output is correct
93 Correct 35 ms 208 KB Output is correct
94 Correct 45 ms 208 KB Output is correct
95 Correct 30 ms 208 KB Output is correct
96 Correct 57 ms 208 KB Output is correct
97 Correct 13 ms 208 KB Output is correct