Submission #622729

# Submission time Handle Problem Language Result Execution time Memory
622729 2022-08-04T13:52:56 Z pawned The Big Prize (IOI17_prize) C++17
92.68 / 100
78 ms 1992 KB
#include "prize.h"

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

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

int N;

ii ans[200005];

set<int> pos;

void query(int n) {
	vi res = ask(n);
	ans[n] = {res[0], res[1]};
}

int most = 0;

void dq(int left, int right) {	// is there a sus in [left, right]?
//	cout<<"at "<<left<<", "<<right<<endl;
	if (left > right)
		return;
	if (ans[left].fi == -1)
		query(left);
	if (ans[right].fi == -1)
		query(right);
	if (ans[left].fi + ans[left].se != most) {
		pos.insert(left);
		dq(left + 1, right);
		return;
	}
	if (ans[right].fi + ans[right].se != most) {
		pos.insert(right);
		dq(left, right - 1);
		return;
	}
	if (ans[left].se == ans[right].se)
		return;
	int mid = (left + right) / 2;
	dq(left, mid);
	dq(mid, right);
}


int find_best(int n) {
	N = n;
/*
	if (N < 10000) {
		for (int i = 0; i < N; i++) {
			vi res = ask(i);
			if (res[0] + res[1] == 0)
				return i;
		}
		return 0;
	}
*/
	for (int i = 0; i < N; i++) {
		ans[i] = {-1, -1};
	}
	for (int i = 0; i < min(N - 1, 500); i++) {
		query(i);
		most = max(most, ans[i].fi + ans[i].se);
	}
//	cout<<"most is "<<most<<endl;
	query(0);
	query(N - 1);
	dq(0, N - 1);
/*
	cout<<"pos: ";
	for (int i : pos)
		cout<<i<<" ";
	cout<<endl;
*/
	for (int i : pos) {
		query(i);
		if (ans[i].fi + ans[i].se == 0)
			return i;
	}
	return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1744 KB Output is correct
2 Correct 3 ms 1836 KB Output is correct
3 Correct 6 ms 1744 KB Output is correct
4 Correct 5 ms 1744 KB Output is correct
5 Correct 7 ms 1744 KB Output is correct
6 Correct 4 ms 1832 KB Output is correct
7 Correct 6 ms 1744 KB Output is correct
8 Correct 6 ms 1840 KB Output is correct
9 Correct 3 ms 1744 KB Output is correct
10 Correct 6 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1744 KB Output is correct
2 Correct 6 ms 1744 KB Output is correct
3 Correct 7 ms 1836 KB Output is correct
4 Correct 3 ms 1836 KB Output is correct
5 Correct 5 ms 1840 KB Output is correct
6 Correct 6 ms 1836 KB Output is correct
7 Correct 7 ms 1836 KB Output is correct
8 Correct 3 ms 1832 KB Output is correct
9 Correct 3 ms 1872 KB Output is correct
10 Correct 10 ms 1744 KB Output is correct
11 Correct 7 ms 1832 KB Output is correct
12 Correct 9 ms 1836 KB Output is correct
13 Correct 10 ms 1744 KB Output is correct
14 Correct 10 ms 464 KB Output is correct
15 Correct 42 ms 1744 KB Output is correct
16 Partially correct 57 ms 1860 KB Partially correct - number of queries: 5535
17 Partially correct 47 ms 1852 KB Partially correct - number of queries: 5113
18 Partially correct 44 ms 1872 KB Partially correct - number of queries: 5586
19 Correct 49 ms 1860 KB Output is correct
20 Correct 26 ms 976 KB Output is correct
21 Partially correct 52 ms 1864 KB Partially correct - number of queries: 5276
22 Correct 25 ms 1956 KB Output is correct
23 Correct 8 ms 1744 KB Output is correct
24 Correct 10 ms 1828 KB Output is correct
25 Correct 47 ms 1856 KB Output is correct
26 Correct 42 ms 1872 KB Output is correct
27 Correct 5 ms 1832 KB Output is correct
28 Partially correct 22 ms 1992 KB Partially correct - number of queries: 5065
29 Correct 42 ms 1836 KB Output is correct
30 Partially correct 78 ms 1848 KB Partially correct - number of queries: 5556
31 Partially correct 44 ms 1828 KB Partially correct - number of queries: 5083
32 Correct 9 ms 1836 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Partially correct 21 ms 1880 KB Partially correct - number of queries: 5270
35 Correct 4 ms 1864 KB Output is correct
36 Partially correct 56 ms 1860 KB Partially correct - number of queries: 5160
37 Correct 9 ms 1832 KB Output is correct
38 Correct 6 ms 1744 KB Output is correct
39 Partially correct 54 ms 1860 KB Partially correct - number of queries: 5266
40 Correct 39 ms 1864 KB Output is correct
41 Partially correct 50 ms 1988 KB Partially correct - number of queries: 5372
42 Partially correct 22 ms 1880 KB Partially correct - number of queries: 5372
43 Partially correct 21 ms 1860 KB Partially correct - number of queries: 5248
44 Partially correct 46 ms 1864 KB Partially correct - number of queries: 5310
45 Correct 48 ms 1972 KB Output is correct
46 Partially correct 56 ms 1960 KB Partially correct - number of queries: 5111
47 Correct 43 ms 1992 KB Output is correct
48 Partially correct 27 ms 1868 KB Partially correct - number of queries: 5436
49 Partially correct 57 ms 1992 KB Partially correct - number of queries: 5129
50 Partially correct 59 ms 1872 KB Partially correct - number of queries: 5594
51 Partially correct 53 ms 1852 KB Partially correct - number of queries: 5299
52 Partially correct 40 ms 1956 KB Partially correct - number of queries: 5136
53 Correct 8 ms 1840 KB Output is correct
54 Partially correct 22 ms 1864 KB Partially correct - number of queries: 5290
55 Partially correct 59 ms 1864 KB Partially correct - number of queries: 5116
56 Partially correct 30 ms 1864 KB Partially correct - number of queries: 5568
57 Partially correct 27 ms 1872 KB Partially correct - number of queries: 5426
58 Partially correct 28 ms 1864 KB Partially correct - number of queries: 5441
59 Partially correct 43 ms 1852 KB Partially correct - number of queries: 5380
60 Partially correct 31 ms 1868 KB Partially correct - number of queries: 5306
61 Correct 7 ms 1836 KB Output is correct
62 Correct 7 ms 1736 KB Output is correct
63 Correct 3 ms 1872 KB Output is correct
64 Correct 8 ms 1832 KB Output is correct
65 Correct 7 ms 1816 KB Output is correct
66 Correct 16 ms 1836 KB Output is correct
67 Correct 9 ms 1840 KB Output is correct
68 Correct 7 ms 1860 KB Output is correct
69 Correct 9 ms 1812 KB Output is correct
70 Correct 4 ms 1864 KB Output is correct
71 Partially correct 39 ms 1868 KB Partially correct - number of queries: 5732
72 Correct 11 ms 1744 KB Output is correct
73 Partially correct 44 ms 1744 KB Partially correct - number of queries: 5662
74 Partially correct 50 ms 1868 KB Partially correct - number of queries: 5692
75 Correct 6 ms 1744 KB Output is correct
76 Partially correct 47 ms 1860 KB Partially correct - number of queries: 5012
77 Partially correct 50 ms 1860 KB Partially correct - number of queries: 5670
78 Correct 6 ms 1744 KB Output is correct
79 Correct 24 ms 1744 KB Output is correct
80 Partially correct 62 ms 1864 KB Partially correct - number of queries: 5691
81 Partially correct 23 ms 1904 KB Partially correct - number of queries: 5647
82 Partially correct 55 ms 1984 KB Partially correct - number of queries: 5629
83 Correct 7 ms 1836 KB Output is correct
84 Correct 20 ms 1868 KB Output is correct
85 Partially correct 42 ms 1860 KB Partially correct - number of queries: 5696
86 Correct 7 ms 1864 KB Output is correct
87 Correct 8 ms 1840 KB Output is correct
88 Correct 7 ms 1868 KB Output is correct
89 Correct 7 ms 1860 KB Output is correct
90 Correct 4 ms 1836 KB Output is correct
91 Correct 9 ms 1872 KB Output is correct
92 Correct 5 ms 1864 KB Output is correct
93 Correct 12 ms 1868 KB Output is correct
94 Correct 15 ms 1868 KB Output is correct
95 Correct 15 ms 1872 KB Output is correct
96 Correct 9 ms 1868 KB Output is correct
97 Correct 8 ms 1868 KB Output is correct