Submission #134520

# Submission time Handle Problem Language Result Execution time Memory
134520 2019-07-23T02:23:11 Z dvdg6566 The Big Prize (IOI17_prize) C++14
95.04 / 100
70 ms 1648 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()

int MAXQ = 0;
vi nextrow,cur;
vi currow;

void dnc(int s, int e, int loff, int roff){
	if (s > e)return;
	// cout<<"DNC "<<s<<' '<<e<<' '<<loff<<' '<<roff<<'\n';
	if (loff + roff == MAXQ)return; // None exist in this range
	if (s == e){
		nextrow.pb(currow[s]);
		return;
	}

	int m = (s+e)/2;
	int done=0;

	while(m<=e){
		cur = ask(currow[m]);
		// cout<<"Query "<<m<<' '<<cur[0]<<' '<<cur[1]<<'\n';
		if (cur[0]+cur[1] == MAXQ)break;
		nextrow.pb(currow[m]);
		++done;
		++m;
	}
	pi x = mp(cur[0],cur[1]);
	int lm = (s+e)/2;
	dnc(s,lm-1,loff,x.s+done);
	dnc(m+1,e,x.f,roff);
}

int find_best(int n) {
	for (int i=0;i<n;++i)currow.pb(i);
	while(1){
		MAXQ = 0;
		for (int i=0;i<500&&i<SZ(currow);++i){
			vi x = ask(currow[i]);
			MAXQ = max(MAXQ, x[0] + x[1]);
		}
		// cout<<MAXQ<<'\n';
		dnc(0,SZ(currow)-1,0,0);
		// for (auto i : nextrow)cout<<i<<' ';cout<<'\n';
		// if (SZ(nextrow) == 2)break;
		sort(ALL(nextrow));
		if(SZ(nextrow) == 1)return nextrow[0];
		swap(nextrow,currow);
		nextrow.clear();
	}


	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1392 KB Output is correct
2 Correct 6 ms 1520 KB Output is correct
3 Correct 9 ms 1516 KB Output is correct
4 Correct 11 ms 1452 KB Output is correct
5 Correct 9 ms 1392 KB Output is correct
6 Correct 10 ms 1392 KB Output is correct
7 Correct 8 ms 1388 KB Output is correct
8 Correct 8 ms 1520 KB Output is correct
9 Correct 9 ms 1520 KB Output is correct
10 Correct 8 ms 1440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1392 KB Output is correct
2 Correct 9 ms 1388 KB Output is correct
3 Correct 9 ms 1392 KB Output is correct
4 Correct 6 ms 1520 KB Output is correct
5 Correct 6 ms 1444 KB Output is correct
6 Correct 6 ms 1520 KB Output is correct
7 Correct 9 ms 1536 KB Output is correct
8 Correct 8 ms 1440 KB Output is correct
9 Correct 9 ms 1536 KB Output is correct
10 Correct 10 ms 1520 KB Output is correct
11 Correct 15 ms 1536 KB Output is correct
12 Correct 14 ms 1516 KB Output is correct
13 Correct 17 ms 1388 KB Output is correct
14 Correct 19 ms 504 KB Output is correct
15 Partially correct 58 ms 1448 KB Partially correct - number of queries: 5034
16 Partially correct 70 ms 1532 KB Partially correct - number of queries: 5496
17 Partially correct 31 ms 1456 KB Partially correct - number of queries: 5416
18 Partially correct 64 ms 1392 KB Partially correct - number of queries: 5426
19 Partially correct 50 ms 1448 KB Partially correct - number of queries: 5091
20 Correct 41 ms 1044 KB Output is correct
21 Partially correct 31 ms 1388 KB Partially correct - number of queries: 5373
22 Correct 33 ms 1520 KB Output is correct
23 Correct 10 ms 1392 KB Output is correct
24 Correct 14 ms 1448 KB Output is correct
25 Partially correct 36 ms 1388 KB Partially correct - number of queries: 5023
26 Partially correct 53 ms 1448 KB Partially correct - number of queries: 5012
27 Correct 9 ms 1392 KB Output is correct
28 Correct 59 ms 1392 KB Output is correct
29 Correct 49 ms 1540 KB Output is correct
30 Partially correct 57 ms 1392 KB Partially correct - number of queries: 5347
31 Partially correct 61 ms 1392 KB Partially correct - number of queries: 5349
32 Correct 13 ms 1452 KB Output is correct
33 Correct 4 ms 248 KB Output is correct
34 Partially correct 53 ms 1392 KB Partially correct - number of queries: 5419
35 Correct 13 ms 1440 KB Output is correct
36 Partially correct 50 ms 1392 KB Partially correct - number of queries: 5342
37 Correct 13 ms 1392 KB Output is correct
38 Correct 7 ms 1644 KB Output is correct
39 Partially correct 51 ms 1440 KB Partially correct - number of queries: 5314
40 Correct 50 ms 1388 KB Output is correct
41 Partially correct 61 ms 1452 KB Partially correct - number of queries: 5394
42 Partially correct 40 ms 1452 KB Partially correct - number of queries: 5394
43 Partially correct 61 ms 1388 KB Partially correct - number of queries: 5301
44 Partially correct 53 ms 1392 KB Partially correct - number of queries: 5422
45 Partially correct 51 ms 1392 KB Partially correct - number of queries: 5006
46 Partially correct 31 ms 1520 KB Partially correct - number of queries: 5420
47 Partially correct 51 ms 1392 KB Partially correct - number of queries: 5080
48 Partially correct 55 ms 1396 KB Partially correct - number of queries: 5397
49 Partially correct 49 ms 1524 KB Partially correct - number of queries: 5408
50 Partially correct 59 ms 1392 KB Partially correct - number of queries: 5422
51 Partially correct 52 ms 1392 KB Partially correct - number of queries: 5425
52 Partially correct 36 ms 1396 KB Partially correct - number of queries: 5408
53 Correct 10 ms 1392 KB Output is correct
54 Partially correct 30 ms 1448 KB Partially correct - number of queries: 5377
55 Partially correct 64 ms 1392 KB Partially correct - number of queries: 5408
56 Partially correct 59 ms 1516 KB Partially correct - number of queries: 5407
57 Partially correct 56 ms 1392 KB Partially correct - number of queries: 5374
58 Partially correct 40 ms 1648 KB Partially correct - number of queries: 5383
59 Partially correct 57 ms 1440 KB Partially correct - number of queries: 5400
60 Partially correct 35 ms 1408 KB Partially correct - number of queries: 5347
61 Correct 12 ms 1392 KB Output is correct
62 Correct 10 ms 1392 KB Output is correct
63 Correct 10 ms 1388 KB Output is correct
64 Correct 12 ms 1516 KB Output is correct
65 Correct 7 ms 1452 KB Output is correct
66 Correct 11 ms 1648 KB Output is correct
67 Correct 19 ms 1452 KB Output is correct
68 Correct 21 ms 1392 KB Output is correct
69 Correct 20 ms 1388 KB Output is correct
70 Correct 14 ms 1392 KB Output is correct
71 Partially correct 60 ms 1392 KB Partially correct - number of queries: 5329
72 Correct 9 ms 1456 KB Output is correct
73 Partially correct 53 ms 1388 KB Partially correct - number of queries: 5304
74 Partially correct 61 ms 1452 KB Partially correct - number of queries: 5275
75 Correct 11 ms 1392 KB Output is correct
76 Correct 43 ms 1536 KB Output is correct
77 Partially correct 54 ms 1520 KB Partially correct - number of queries: 5361
78 Correct 13 ms 1392 KB Output is correct
79 Correct 32 ms 1392 KB Output is correct
80 Partially correct 58 ms 1392 KB Partially correct - number of queries: 5381
81 Partially correct 59 ms 1520 KB Partially correct - number of queries: 5367
82 Partially correct 31 ms 1516 KB Partially correct - number of queries: 5307
83 Correct 10 ms 1392 KB Output is correct
84 Correct 55 ms 1388 KB Output is correct
85 Partially correct 53 ms 1392 KB Partially correct - number of queries: 5373
86 Correct 16 ms 1448 KB Output is correct
87 Correct 7 ms 1520 KB Output is correct
88 Correct 19 ms 1392 KB Output is correct
89 Correct 20 ms 1392 KB Output is correct
90 Correct 9 ms 1436 KB Output is correct
91 Correct 15 ms 1456 KB Output is correct
92 Correct 17 ms 1392 KB Output is correct
93 Correct 26 ms 1392 KB Output is correct
94 Correct 26 ms 1396 KB Output is correct
95 Correct 23 ms 1392 KB Output is correct
96 Correct 19 ms 1392 KB Output is correct
97 Correct 18 ms 1392 KB Output is correct