Submission #1012778

# Submission time Handle Problem Language Result Execution time Memory
1012778 2024-07-02T15:10:55 Z ThegeekKnight16 The Big Prize (IOI17_prize) C++17
20 / 100
37 ms 1452 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
map<int, vector<int>> ans;

vector<int> query(int x)
{
    if (ans.count(x)) return ans[x];
    return ans[x] = ask(x);
}

int dc(int ini, int fim, int qMen, int qL, int qR)
{
    //Cases in which i don't have to test
    if (ini > fim || qL + qR == qMen) return -1;
    if (fim - ini <= 1)
    {
        vector<int> aL = query(ini), aR = query(fim);
        if (aL[0]+aL[1] == 0) return ini;
        if (aR[0]+aR[1] == 0) return fim;
        return -1;
    }
    if (query(ini) == query(fim)) return -1;

    //get middle expensive
    int mL = (ini+fim)>>1, mR = (ini+fim)>>1;
    vector<int> aL, aR;
    while (mL >= ini)
    {
        aL = query(mL);
        if (aL[0]+aL[1] == 0) return mL;
        if (aL[0]+aL[1] < qMen) --mL;
        else break;
    }
    while (mR <= fim)
    {
        aR = query(mR);
        if (aR[0]+aR[1] == 0) return mR;
        if (aR[0]+aR[1] < qMen) ++mR;
        else break;
    }

    //then divide and conquer
    int x = dc(mR, fim, qMen, aR[0], qR);
    if (x == -1) return dc(ini, mL, qMen, qL, aL[1]);
    return x;

}

int find_best(int n)
{
    //here to find expensive quantity -> P(expensive) ~ 1/sqrt(N)
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    vector<int> ids;
    for (int i = 0; i < 10; i++) ids.push_back(uniform_int_distribution<int>(0, n-1)(rng));
    vector<vector<int>> possQ;
    for (auto x : ids) possQ.push_back(query(x));
    int qMen = 1;
    for (auto &x : possQ) qMen = max(qMen, x[0]+x[1]);

    return dc(0, n-1, qMen, 0, 0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 424 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 7 ms 600 KB Output is correct
15 Correct 19 ms 772 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 26 ms 896 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 24 ms 848 KB Output is correct
20 Correct 9 ms 600 KB Output is correct
21 Correct 13 ms 600 KB Output is correct
22 Correct 16 ms 776 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 480 KB Output is correct
25 Correct 9 ms 600 KB Output is correct
26 Correct 9 ms 928 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 20 ms 848 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 17 ms 600 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 22 ms 600 KB Output is correct
37 Correct 2 ms 596 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 16 ms 600 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 11 ms 600 KB Output is correct
42 Correct 12 ms 776 KB Output is correct
43 Correct 13 ms 600 KB Output is correct
44 Correct 15 ms 724 KB Output is correct
45 Correct 13 ms 728 KB Output is correct
46 Correct 32 ms 1452 KB Output is correct
47 Correct 14 ms 840 KB Output is correct
48 Correct 10 ms 344 KB Output is correct
49 Correct 23 ms 848 KB Output is correct
50 Correct 0 ms 344 KB Output is correct
51 Correct 19 ms 600 KB Output is correct
52 Correct 22 ms 924 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 14 ms 600 KB Output is correct
55 Correct 20 ms 848 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 7 ms 600 KB Output is correct
58 Correct 8 ms 600 KB Output is correct
59 Correct 11 ms 664 KB Output is correct
60 Correct 16 ms 592 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 2 ms 344 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 3 ms 424 KB Output is correct
67 Correct 1 ms 344 KB Output is correct
68 Correct 3 ms 436 KB Output is correct
69 Correct 3 ms 344 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 27 ms 808 KB Output is correct
72 Correct 2 ms 344 KB Output is correct
73 Correct 20 ms 800 KB Output is correct
74 Correct 25 ms 1012 KB Output is correct
75 Correct 1 ms 344 KB Output is correct
76 Correct 23 ms 848 KB Output is correct
77 Correct 18 ms 924 KB Output is correct
78 Correct 3 ms 344 KB Output is correct
79 Correct 8 ms 600 KB Output is correct
80 Correct 20 ms 856 KB Output is correct
81 Correct 22 ms 848 KB Output is correct
82 Correct 33 ms 848 KB Output is correct
83 Correct 1 ms 344 KB Output is correct
84 Correct 20 ms 848 KB Output is correct
85 Correct 37 ms 852 KB Output is correct
86 Correct 3 ms 600 KB Output is correct
87 Incorrect 3 ms 344 KB Integer -1 violates the range [0, 199999]
88 Halted 0 ms 0 KB -