Submission #221802

# Submission time Handle Problem Language Result Execution time Memory
221802 2020-04-11T07:54:55 Z patrikpavic2 The Big Prize (IOI17_prize) C++17
100 / 100
57 ms 2136 KB
/**
* user:  ppavic
* fname: Patrik
* lname: Pavić
* task:  prize
* score: 100.0
* date:  2019-06-16 09:02:45.353752
*/
#include "prize.h"
#include <vector>
#include <algorithm>
#include <cstring>

#define PB push_back

using namespace std;

typedef vector < int > vi;

const int N = 2e5 + 500;

int L[N], R[N];

int get_L(int i){
    if(L[i] != -1) return L[i];
    vi res = ask(i);
    L[i] = res[0], R[i] = res[1];
    return L[i];
}

int get_R(int i){
    if(L[i] != -1) return R[i];
    vi res = ask(i);
    L[i] = res[0], R[i] = res[1];
    return R[i];
}

int loli;
vi svi;

void solve(int l,int r){
    if(l > r) return;
    if(get_L(l) + get_R(l) < loli){
        svi.PB(l); solve(l + 1, r);
        return;
    }
    if(l == r) return;
    if(get_L(r) + get_R(r) < loli){
        svi.PB(r); solve(l, r - 1);
        return;
    }
    if(get_L(l) == get_L(r) || l + 1 == r) return;
    solve(l, (l + r) / 2);
    solve((l + r) / 2, r);
}


int find_best(int n) {
    memset(L, -1, sizeof(L));
    svi.clear();
	loli = 0;
	for(int i = 0;i < 100;i++){
        int x = (rand() + rand()) % n;
        x = (x % n + n) % n;
        loli = max(loli, get_L(x) + get_R(x));
	}
    solve(0, n - 1);
    for(int x : svi){
        if(get_L(x) + get_R(x) == 0)
            return x;
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1536 KB Output is correct
2 Correct 6 ms 1408 KB Output is correct
3 Correct 8 ms 1400 KB Output is correct
4 Correct 6 ms 1408 KB Output is correct
5 Correct 6 ms 1536 KB Output is correct
6 Correct 7 ms 1400 KB Output is correct
7 Correct 6 ms 1432 KB Output is correct
8 Correct 6 ms 1408 KB Output is correct
9 Correct 6 ms 1428 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1408 KB Output is correct
2 Correct 6 ms 1408 KB Output is correct
3 Correct 6 ms 1408 KB Output is correct
4 Correct 6 ms 1408 KB Output is correct
5 Correct 6 ms 1400 KB Output is correct
6 Correct 6 ms 1408 KB Output is correct
7 Correct 6 ms 1408 KB Output is correct
8 Correct 7 ms 1536 KB Output is correct
9 Correct 6 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 8 ms 1748 KB Output is correct
12 Correct 10 ms 1784 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 38 ms 1912 KB Output is correct
16 Correct 48 ms 1888 KB Output is correct
17 Correct 47 ms 1836 KB Output is correct
18 Correct 44 ms 1896 KB Output is correct
19 Correct 42 ms 1916 KB Output is correct
20 Correct 31 ms 1528 KB Output is correct
21 Correct 51 ms 1912 KB Output is correct
22 Correct 49 ms 1912 KB Output is correct
23 Correct 7 ms 1536 KB Output is correct
24 Correct 9 ms 1656 KB Output is correct
25 Correct 43 ms 1912 KB Output is correct
26 Correct 36 ms 1916 KB Output is correct
27 Correct 8 ms 1528 KB Output is correct
28 Correct 40 ms 1912 KB Output is correct
29 Correct 23 ms 1924 KB Output is correct
30 Correct 50 ms 1916 KB Output is correct
31 Correct 39 ms 1912 KB Output is correct
32 Correct 11 ms 1664 KB Output is correct
33 Correct 6 ms 1152 KB Output is correct
34 Correct 47 ms 1912 KB Output is correct
35 Correct 8 ms 1536 KB Output is correct
36 Correct 39 ms 1912 KB Output is correct
37 Correct 9 ms 1656 KB Output is correct
38 Correct 6 ms 1552 KB Output is correct
39 Correct 38 ms 2048 KB Output is correct
40 Correct 43 ms 1912 KB Output is correct
41 Correct 51 ms 1912 KB Output is correct
42 Correct 41 ms 1912 KB Output is correct
43 Correct 57 ms 1828 KB Output is correct
44 Correct 54 ms 1912 KB Output is correct
45 Correct 43 ms 1912 KB Output is correct
46 Correct 53 ms 1916 KB Output is correct
47 Correct 49 ms 1912 KB Output is correct
48 Correct 45 ms 1912 KB Output is correct
49 Correct 46 ms 1900 KB Output is correct
50 Correct 33 ms 1960 KB Output is correct
51 Correct 41 ms 1892 KB Output is correct
52 Correct 56 ms 1916 KB Output is correct
53 Correct 7 ms 1536 KB Output is correct
54 Correct 38 ms 2136 KB Output is correct
55 Correct 50 ms 1916 KB Output is correct
56 Correct 39 ms 1884 KB Output is correct
57 Correct 47 ms 1912 KB Output is correct
58 Correct 52 ms 1912 KB Output is correct
59 Correct 41 ms 1912 KB Output is correct
60 Correct 42 ms 1912 KB Output is correct
61 Correct 7 ms 1536 KB Output is correct
62 Correct 7 ms 1536 KB Output is correct
63 Correct 9 ms 1528 KB Output is correct
64 Correct 7 ms 1528 KB Output is correct
65 Correct 7 ms 1400 KB Output is correct
66 Correct 10 ms 1528 KB Output is correct
67 Correct 11 ms 1408 KB Output is correct
68 Correct 9 ms 1400 KB Output is correct
69 Correct 8 ms 1508 KB Output is correct
70 Correct 10 ms 1528 KB Output is correct
71 Correct 47 ms 1912 KB Output is correct
72 Correct 11 ms 1792 KB Output is correct
73 Correct 50 ms 1916 KB Output is correct
74 Correct 34 ms 1912 KB Output is correct
75 Correct 7 ms 1536 KB Output is correct
76 Correct 26 ms 1944 KB Output is correct
77 Correct 46 ms 1912 KB Output is correct
78 Correct 10 ms 1792 KB Output is correct
79 Correct 26 ms 1916 KB Output is correct
80 Correct 41 ms 1852 KB Output is correct
81 Correct 48 ms 1912 KB Output is correct
82 Correct 48 ms 1912 KB Output is correct
83 Correct 7 ms 1536 KB Output is correct
84 Correct 34 ms 1912 KB Output is correct
85 Correct 50 ms 1912 KB Output is correct
86 Correct 18 ms 1772 KB Output is correct
87 Correct 12 ms 1536 KB Output is correct
88 Correct 18 ms 1656 KB Output is correct
89 Correct 20 ms 1912 KB Output is correct
90 Correct 7 ms 1536 KB Output is correct
91 Correct 17 ms 1664 KB Output is correct
92 Correct 19 ms 1656 KB Output is correct
93 Correct 9 ms 1536 KB Output is correct
94 Correct 10 ms 1664 KB Output is correct
95 Correct 9 ms 1664 KB Output is correct
96 Correct 8 ms 1536 KB Output is correct
97 Correct 6 ms 1408 KB Output is correct