Submission #1012330

# Submission time Handle Problem Language Result Execution time Memory
1012330 2024-07-01T23:56:24 Z ThegeekKnight16 The Big Prize (IOI17_prize) C++17
20 / 100
61 ms 1556 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
int Q = 10000;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
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)
{
    // cerr << "ini: " << ini << ", fim: " << fim << '\n';
    if (ini > fim || qL + qR == qMen) return -1;
    if (qMen - (qL + qR) == fim - ini + 1)
    {
        for (int i = ini; i <= fim; i++)
        {
            vector<int> a = query(i);
            if (a[0]+a[1] == 0) return i;
        }
        return -1;
    }
    int mL = (ini+fim)>>1, mR = (ini+fim)>>1;
    vector<int> aL, aR;
    bool excludeL = 0, excludeD = 0;
    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;
    }

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

}

int find_best(int n)
{
    // if (n <= 5000)
    // {
    //     vector<int> ids(n); iota(ids.begin(), ids.end(), 0);
    //     shuffle(ids.begin(), ids.end(), rng);
    //     for (auto i : ids)
    //     {
    //         vector<int> a = query(i);
    //         if (a[0]+a[1] == 0) return i;
    //     }
    // }
    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);
}

Compilation message

prize.cpp: In function 'int dc(int, int, int, int, int)':
prize.cpp:29:10: warning: unused variable 'excludeL' [-Wunused-variable]
   29 |     bool excludeL = 0, excludeD = 0;
      |          ^~~~~~~~
prize.cpp:29:24: warning: unused variable 'excludeD' [-Wunused-variable]
   29 |     bool excludeL = 0, excludeD = 0;
      |                        ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 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 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 408 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 20 ms 636 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 18 ms 848 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 17 ms 1032 KB Output is correct
20 Correct 8 ms 600 KB Output is correct
21 Correct 13 ms 600 KB Output is correct
22 Correct 16 ms 600 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 8 ms 600 KB Output is correct
26 Correct 7 ms 600 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 23 ms 840 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 13 ms 684 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 19 ms 708 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 432 KB Output is correct
39 Correct 9 ms 600 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 8 ms 600 KB Output is correct
42 Correct 7 ms 600 KB Output is correct
43 Correct 9 ms 860 KB Output is correct
44 Correct 12 ms 676 KB Output is correct
45 Correct 14 ms 736 KB Output is correct
46 Correct 13 ms 844 KB Output is correct
47 Correct 10 ms 688 KB Output is correct
48 Correct 5 ms 484 KB Output is correct
49 Correct 16 ms 848 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 12 ms 652 KB Output is correct
52 Correct 19 ms 848 KB Output is correct
53 Correct 0 ms 344 KB Output is correct
54 Correct 15 ms 600 KB Output is correct
55 Correct 29 ms 844 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 6 ms 344 KB Output is correct
58 Correct 6 ms 344 KB Output is correct
59 Correct 8 ms 600 KB Output is correct
60 Correct 9 ms 600 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 0 ms 344 KB Output is correct
64 Correct 0 ms 340 KB Output is correct
65 Correct 0 ms 424 KB Output is correct
66 Correct 2 ms 344 KB Output is correct
67 Correct 1 ms 344 KB Output is correct
68 Correct 2 ms 600 KB Output is correct
69 Correct 2 ms 344 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 16 ms 848 KB Output is correct
72 Correct 2 ms 344 KB Output is correct
73 Correct 26 ms 904 KB Output is correct
74 Correct 15 ms 856 KB Output is correct
75 Correct 1 ms 344 KB Output is correct
76 Correct 13 ms 624 KB Output is correct
77 Correct 19 ms 848 KB Output is correct
78 Correct 3 ms 856 KB Output is correct
79 Correct 10 ms 856 KB Output is correct
80 Correct 25 ms 880 KB Output is correct
81 Correct 25 ms 796 KB Output is correct
82 Correct 20 ms 856 KB Output is correct
83 Correct 1 ms 600 KB Output is correct
84 Correct 15 ms 848 KB Output is correct
85 Correct 19 ms 848 KB Output is correct
86 Incorrect 61 ms 1556 KB Incorrect
87 Halted 0 ms 0 KB -