Submission #321595

# Submission time Handle Problem Language Result Execution time Memory
321595 2020-11-12T20:18:33 Z 12tqian The Big Prize (IOI17_prize) C++17
20 / 100
215 ms 9892 KB
#include "prize.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define f first
#define s second
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());

int find_best(int n) {
    if (n <= 7) {
            for(int i = 0; i < n; i++) {
            std::vector<int> res = ask(i);
            if(res[0] + res[1] == 0)
                return i;
        }
    }
    const int TIMES = 20;
    int lim  = 0;
    for (int i = 0; i < TIMES; i++) {
        vector<int> q = ask(rng() % n);
        lim = max(lim, q[0] + q[1]);
    }
    Tree<int> rem; // not identified
    Tree<int> done;
    for (int i = 0; i < n; i++) {
        rem.insert(i);
    }
    while (true) {
        bool ok = false;
        int lo = 0;
        int hi = sz(rem) - 1;
        while (hi - lo > 1) {
            int mid = (lo + hi) / 2;
            int id = *rem.find_by_order(mid);
            vector<int> q = ask(id);
            if (q[0] + q[1] == 0) {
                return id;
            } else if (q[0] + q[1] < lim) {
                rem.erase(id);
                done.insert(id);
                ok = true;
                break;
            } else {
                q[0] -= done.order_of_key(id);
                q[1] -= sz(done) - done.order_of_key(id);
                if (q[0]) {
                    hi = mid - 1;
                } else {
                    lo = mid + 1;
                }
            }
        }
        if (ok) continue;
        int id = *rem.find_by_order(lo);
        vector<int> q = ask(id);
        if (q[0] + q[1] < lim) {
            if (q[0] + q[1] == 0) {
                return id;
            } else {
                rem.erase(id);
                done.insert(id);
            }
        } else {
            id = *rem.find_by_order(hi);
            q = ask(id);
            if (q[0] + q[1] == 0) {
                return id;
            } else {
                rem.erase(id);
                done.insert(id);
            }
        }
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 109 ms 9708 KB Output is correct
2 Correct 108 ms 9844 KB Output is correct
3 Correct 107 ms 9708 KB Output is correct
4 Correct 111 ms 9716 KB Output is correct
5 Correct 109 ms 9852 KB Output is correct
6 Correct 108 ms 9728 KB Output is correct
7 Correct 109 ms 9748 KB Output is correct
8 Correct 108 ms 9728 KB Output is correct
9 Correct 110 ms 9836 KB Output is correct
10 Correct 109 ms 9760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 9708 KB Output is correct
2 Correct 109 ms 9764 KB Output is correct
3 Correct 109 ms 9708 KB Output is correct
4 Correct 109 ms 9844 KB Output is correct
5 Correct 110 ms 9708 KB Output is correct
6 Correct 109 ms 9708 KB Output is correct
7 Correct 108 ms 9708 KB Output is correct
8 Correct 108 ms 9836 KB Output is correct
9 Correct 108 ms 9708 KB Output is correct
10 Correct 109 ms 9708 KB Output is correct
11 Correct 114 ms 9708 KB Output is correct
12 Correct 108 ms 9836 KB Output is correct
13 Correct 114 ms 9708 KB Output is correct
14 Correct 11 ms 1260 KB Output is correct
15 Correct 122 ms 9708 KB Output is correct
16 Partially correct 192 ms 9708 KB Partially correct - number of queries: 6528
17 Correct 108 ms 9708 KB Output is correct
18 Partially correct 214 ms 9708 KB Partially correct - number of queries: 7867
19 Correct 108 ms 9708 KB Output is correct
20 Correct 67 ms 4972 KB Output is correct
21 Correct 142 ms 9844 KB Output is correct
22 Correct 115 ms 9804 KB Output is correct
23 Correct 108 ms 9844 KB Output is correct
24 Correct 108 ms 9708 KB Output is correct
25 Correct 135 ms 9708 KB Output is correct
26 Correct 163 ms 9708 KB Output is correct
27 Correct 109 ms 9836 KB Output is correct
28 Partially correct 177 ms 9708 KB Partially correct - number of queries: 7425
29 Partially correct 171 ms 9724 KB Partially correct - number of queries: 5583
30 Partially correct 215 ms 9708 KB Partially correct - number of queries: 7777
31 Correct 109 ms 9708 KB Output is correct
32 Correct 111 ms 9708 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 122 ms 9844 KB Output is correct
35 Correct 110 ms 9744 KB Output is correct
36 Correct 128 ms 9708 KB Output is correct
37 Correct 111 ms 9708 KB Output is correct
38 Correct 108 ms 9836 KB Output is correct
39 Correct 155 ms 9708 KB Output is correct
40 Partially correct 182 ms 9708 KB Partially correct - number of queries: 6621
41 Correct 147 ms 9708 KB Output is correct
42 Correct 150 ms 9892 KB Output is correct
43 Correct 140 ms 9708 KB Output is correct
44 Correct 130 ms 9692 KB Output is correct
45 Correct 128 ms 9708 KB Output is correct
46 Correct 109 ms 9708 KB Output is correct
47 Correct 146 ms 9744 KB Output is correct
48 Partially correct 167 ms 9856 KB Partially correct - number of queries: 5597
49 Correct 114 ms 9724 KB Output is correct
50 Partially correct 181 ms 9708 KB Partially correct - number of queries: 7878
51 Correct 142 ms 9708 KB Output is correct
52 Correct 112 ms 9836 KB Output is correct
53 Correct 111 ms 9836 KB Output is correct
54 Correct 140 ms 9836 KB Output is correct
55 Correct 108 ms 9708 KB Output is correct
56 Partially correct 184 ms 9708 KB Partially correct - number of queries: 7891
57 Partially correct 161 ms 9708 KB Partially correct - number of queries: 5510
58 Partially correct 162 ms 9708 KB Partially correct - number of queries: 5607
59 Correct 145 ms 9800 KB Output is correct
60 Correct 151 ms 9836 KB Output is correct
61 Correct 110 ms 9836 KB Output is correct
62 Correct 109 ms 9708 KB Output is correct
63 Correct 110 ms 9772 KB Output is correct
64 Correct 109 ms 9708 KB Output is correct
65 Correct 113 ms 9708 KB Output is correct
66 Correct 157 ms 9708 KB Output is correct
67 Correct 117 ms 9708 KB Output is correct
68 Correct 115 ms 9836 KB Output is correct
69 Correct 149 ms 9708 KB Output is correct
70 Correct 117 ms 9740 KB Output is correct
71 Partially correct 176 ms 9708 KB Partially correct - number of queries: 8516
72 Correct 114 ms 9708 KB Output is correct
73 Partially correct 183 ms 9708 KB Partially correct - number of queries: 8390
74 Partially correct 190 ms 9876 KB Partially correct - number of queries: 8444
75 Correct 111 ms 9708 KB Output is correct
76 Partially correct 200 ms 9708 KB Partially correct - number of queries: 7220
77 Partially correct 210 ms 9796 KB Partially correct - number of queries: 7940
78 Correct 119 ms 9708 KB Output is correct
79 Correct 145 ms 9844 KB Output is correct
80 Partially correct 179 ms 9708 KB Partially correct - number of queries: 7985
81 Partially correct 201 ms 9708 KB Partially correct - number of queries: 7911
82 Partially correct 190 ms 9708 KB Partially correct - number of queries: 7874
83 Correct 110 ms 9736 KB Output is correct
84 Partially correct 155 ms 9708 KB Partially correct - number of queries: 6513
85 Partially correct 192 ms 9708 KB Partially correct - number of queries: 7950
86 Incorrect 201 ms 9708 KB Incorrect
87 Halted 0 ms 0 KB -