Submission #340826

# Submission time Handle Problem Language Result Execution time Memory
340826 2020-12-28T12:10:49 Z pggp The Big Prize (IOI17_prize) C++14
97.63 / 100
67 ms 2860 KB
#include <bits/stdc++.h>
#include "prize.h"

using namespace std;

int higher[200000];
int left_h[200000];
int right_h[200000];
int N;

void search(int l, int r){
	//cout << l << " " << r << endl;
	if(r < l + 2){
		return;
	}
	if(left_h[l] == left_h[r]){
		return;
	}
	int mid = (r + l) / 2;
	vector < int > a = ask(mid);
	higher[mid] = a[0] + a[1];
	left_h[mid] = a[0];
	right_h[mid] = a[1];
	if(a[0] + a[1] < 2 * sqrt(N)){
		search(l, mid);
		search(mid, r);
	}
	else{
		for (int i = mid - 1; i > l; --i)
		{
			vector < int > a1 = ask(i);
			higher[i] = a1[0] + a1[1];
			left_h[i] = a1[0];
			right_h[i] = a1[1];
			if(a1[0] + a1[1] < 2 * sqrt(N)){
				search(l, i);
			}
		}
		for (int i = mid + 1; i < r; ++i)
		{
			vector < int > a1 = ask(i);
			higher[i] = a1[0] + a1[1];
			left_h[i] = a1[0];
			right_h[i] = a1[1];
			if(a1[0] + a1[1] < 2 * sqrt(N)){
				search(l, i);
			}
		}
	}
}

int find_best(int n){
	N = n;
	for (int i = 0; i < 200000; ++i)
	{
		higher[i] = -1;
	}
	int l_min;
	for (int i = 0; i < n; ++i)
	{
		vector < int > a = ask(i);
		higher[i] = a[0] + a[1];
		left_h[i] = a[0];
		right_h[i] = a[1];
		if(a[0] + a[1] < 2 * sqrt(n)){
			l_min = i;
			break;
		}
	}


	int r_max;
	for (int i = n - 1; i >= 0; --i)
	{
		vector < int > a = ask(i);
		higher[i] = a[0] + a[1];
		left_h[i] = a[0];
		right_h[i] = a[1];
		if(a[0] + a[1] < 2 * sqrt(n)){
			r_max = i;
			break;
		}
	}

	search(l_min, r_max);

	for (int i = 0; i < n; ++i)
	{
			if(higher[i] == 0){
			return i;
		}
	}

}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:94:1: warning: control reaches end of non-void function [-Wreturn-type]
   94 | }
      | ^
prize.cpp:85:8: warning: 'l_min' may be used uninitialized in this function [-Wmaybe-uninitialized]
   85 |  search(l_min, r_max);
      |  ~~~~~~^~~~~~~~~~~~~~
prize.cpp:85:8: warning: 'r_max' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1132 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
5 Correct 2 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 1132 KB Output is correct
8 Correct 1 ms 1132 KB Output is correct
9 Correct 2 ms 1132 KB Output is correct
10 Correct 2 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1132 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 2 ms 1132 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
5 Correct 2 ms 1132 KB Output is correct
6 Correct 1 ms 1284 KB Output is correct
7 Correct 1 ms 1132 KB Output is correct
8 Correct 1 ms 1132 KB Output is correct
9 Correct 2 ms 1284 KB Output is correct
10 Correct 2 ms 1132 KB Output is correct
11 Correct 6 ms 2028 KB Output is correct
12 Correct 6 ms 2028 KB Output is correct
13 Correct 7 ms 2028 KB Output is correct
14 Correct 12 ms 1260 KB Output is correct
15 Correct 45 ms 2668 KB Output is correct
16 Partially correct 53 ms 2668 KB Partially correct - number of queries: 5039
17 Partially correct 54 ms 2688 KB Partially correct - number of queries: 5073
18 Partially correct 53 ms 2828 KB Partially correct - number of queries: 5069
19 Correct 57 ms 2668 KB Output is correct
20 Correct 34 ms 1900 KB Output is correct
21 Partially correct 28 ms 2800 KB Partially correct - number of queries: 5021
22 Correct 34 ms 2668 KB Output is correct
23 Correct 3 ms 1388 KB Output is correct
24 Correct 4 ms 1832 KB Output is correct
25 Correct 60 ms 2668 KB Output is correct
26 Correct 44 ms 2668 KB Output is correct
27 Correct 2 ms 1388 KB Output is correct
28 Correct 37 ms 2672 KB Output is correct
29 Correct 45 ms 2632 KB Output is correct
30 Partially correct 44 ms 2668 KB Partially correct - number of queries: 5023
31 Partially correct 44 ms 2796 KB Partially correct - number of queries: 5028
32 Correct 8 ms 2028 KB Output is correct
33 Correct 2 ms 1132 KB Output is correct
34 Partially correct 45 ms 2668 KB Partially correct - number of queries: 5057
35 Correct 4 ms 1644 KB Output is correct
36 Partially correct 67 ms 2668 KB Partially correct - number of queries: 5065
37 Correct 8 ms 1772 KB Output is correct
38 Correct 3 ms 1388 KB Output is correct
39 Partially correct 47 ms 2668 KB Partially correct - number of queries: 5063
40 Correct 44 ms 2668 KB Output is correct
41 Partially correct 49 ms 2668 KB Partially correct - number of queries: 5094
42 Partially correct 43 ms 2668 KB Partially correct - number of queries: 5094
43 Correct 43 ms 2668 KB Output is correct
44 Partially correct 44 ms 2668 KB Partially correct - number of queries: 5061
45 Correct 40 ms 2668 KB Output is correct
46 Partially correct 50 ms 2668 KB Partially correct - number of queries: 5069
47 Correct 43 ms 2668 KB Output is correct
48 Partially correct 42 ms 2668 KB Partially correct - number of queries: 5081
49 Partially correct 42 ms 2668 KB Partially correct - number of queries: 5083
50 Partially correct 47 ms 2796 KB Partially correct - number of queries: 5070
51 Partially correct 40 ms 2796 KB Partially correct - number of queries: 5073
52 Partially correct 46 ms 2668 KB Partially correct - number of queries: 5062
53 Correct 2 ms 1508 KB Output is correct
54 Partially correct 46 ms 2668 KB Partially correct - number of queries: 5029
55 Partially correct 44 ms 2668 KB Partially correct - number of queries: 5071
56 Partially correct 41 ms 2668 KB Partially correct - number of queries: 5080
57 Partially correct 46 ms 2796 KB Partially correct - number of queries: 5014
58 Partially correct 51 ms 2668 KB Partially correct - number of queries: 5096
59 Partially correct 37 ms 2860 KB Partially correct - number of queries: 5072
60 Partially correct 49 ms 2664 KB Partially correct - number of queries: 5067
61 Correct 3 ms 1532 KB Output is correct
62 Correct 3 ms 1388 KB Output is correct
63 Correct 2 ms 1388 KB Output is correct
64 Correct 2 ms 1392 KB Output is correct
65 Correct 2 ms 1260 KB Output is correct
66 Correct 1 ms 1132 KB Output is correct
67 Correct 2 ms 1132 KB Output is correct
68 Correct 1 ms 1132 KB Output is correct
69 Correct 1 ms 1132 KB Output is correct
70 Correct 1 ms 1132 KB Output is correct
71 Correct 39 ms 2668 KB Output is correct
72 Correct 7 ms 2028 KB Output is correct
73 Correct 37 ms 2796 KB Output is correct
74 Correct 43 ms 2756 KB Output is correct
75 Correct 3 ms 1388 KB Output is correct
76 Correct 58 ms 2668 KB Output is correct
77 Partially correct 30 ms 2832 KB Partially correct - number of queries: 5216
78 Correct 8 ms 2028 KB Output is correct
79 Correct 28 ms 2668 KB Output is correct
80 Partially correct 50 ms 2668 KB Partially correct - number of queries: 5237
81 Partially correct 65 ms 2732 KB Partially correct - number of queries: 5218
82 Partially correct 36 ms 2820 KB Partially correct - number of queries: 5215
83 Correct 3 ms 1388 KB Output is correct
84 Correct 40 ms 2668 KB Output is correct
85 Partially correct 55 ms 2684 KB Partially correct - number of queries: 5227
86 Correct 8 ms 1900 KB Output is correct
87 Correct 5 ms 1772 KB Output is correct
88 Correct 10 ms 1772 KB Output is correct
89 Correct 11 ms 1772 KB Output is correct
90 Correct 3 ms 1388 KB Output is correct
91 Correct 4 ms 1668 KB Output is correct
92 Correct 2 ms 1132 KB Output is correct
93 Correct 6 ms 1644 KB Output is correct
94 Correct 7 ms 1772 KB Output is correct
95 Correct 7 ms 1772 KB Output is correct
96 Correct 4 ms 1636 KB Output is correct
97 Correct 1 ms 1152 KB Output is correct