Submission #784962

# Submission time Handle Problem Language Result Execution time Memory
784962 2023-07-16T20:37:05 Z Sam_a17 The Big Prize (IOI17_prize) C++17
90 / 100
83 ms 2860 KB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ld long double
#define ll long long

#define sz(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define uniq(x) x.resize(unique(all(x)) - x.begin());
#define lb lower_bound
#define ub upper_bound

// for random generations
mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 myrand(131);

std::vector<int> ask(int i);
const int N = 2e5 + 10;
pair<int, int> a[N];
int used[N];

int find_best(int n) {
  memset(used, -1, sizeof(used));

  int mxi = 0;
  for(int i = 0; i < 500; i++) {
    int cur = myrand() % n;
    while (used[cur] == 1) {
      cur = myrand() % n;
    }
    
    auto u = ask(cur);

    a[cur].first = u[0];
    a[cur].second = u[1];
    
    if((u[0] + u[1]) == 0) {
      return cur;
    }

    mxi = max(mxi, u[0] + u[1]);
    used[cur] = 1;
  }

  for(int i = 0; i < n; i++) {
    int ina = i, inb = n - 1, answ = i;
    int lx, rx;
    if(used[i] != -1) {
      lx = a[i].first;
      rx = a[i].second;
    } else {
      auto u = ask(i);

      a[i].first = u[0];
      a[i].second = u[1];

      lx = u[0], rx = u[1];
      used[i] = 1;
    }

    if((lx + rx) == 0) {
      return i;
    }

    if((lx + rx) != mxi) {
      continue;
    }

    while(ina <= inb) {
      int mid = (ina + inb) / 2;
      int l = 0, r = 0;
      if(used[mid] != -1) {
        l = a[mid].first;
        r = a[mid].second;
      } else {
        auto u = ask(mid);

        a[mid].first = u[0];
        a[mid].second = u[1];

        l = u[0], r = u[1];
        used[i] = 1;
      }

      if((l + r) == 0) {
        return mid;
      }

      if(l == lx && (l + r) == (lx + rx)) {
        answ = mid;
        ina = mid + 1;
      } else {
        inb = mid - 1;
      }
    }

    i = answ;
  }

  // xd
  return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2128 KB Output is correct
2 Correct 5 ms 2128 KB Output is correct
3 Correct 6 ms 2088 KB Output is correct
4 Correct 5 ms 2120 KB Output is correct
5 Correct 6 ms 2116 KB Output is correct
6 Correct 5 ms 2112 KB Output is correct
7 Correct 3 ms 2100 KB Output is correct
8 Correct 3 ms 2228 KB Output is correct
9 Correct 4 ms 2128 KB Output is correct
10 Correct 6 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2220 KB Output is correct
2 Correct 5 ms 2100 KB Output is correct
3 Correct 6 ms 2128 KB Output is correct
4 Correct 3 ms 2120 KB Output is correct
5 Correct 5 ms 2128 KB Output is correct
6 Correct 4 ms 2128 KB Output is correct
7 Correct 3 ms 2240 KB Output is correct
8 Correct 3 ms 2124 KB Output is correct
9 Correct 5 ms 2216 KB Output is correct
10 Correct 6 ms 2176 KB Output is correct
11 Correct 5 ms 2280 KB Output is correct
12 Correct 3 ms 2124 KB Output is correct
13 Correct 9 ms 2384 KB Output is correct
14 Correct 8 ms 1232 KB Output is correct
15 Correct 16 ms 2256 KB Output is correct
16 Partially correct 38 ms 2668 KB Partially correct - number of queries: 7812
17 Correct 5 ms 2132 KB Output is correct
18 Partially correct 56 ms 2588 KB Partially correct - number of queries: 9094
19 Correct 3 ms 2148 KB Output is correct
20 Correct 10 ms 1852 KB Output is correct
21 Correct 32 ms 2376 KB Output is correct
22 Correct 10 ms 2344 KB Output is correct
23 Correct 4 ms 2096 KB Output is correct
24 Correct 5 ms 2216 KB Output is correct
25 Partially correct 36 ms 2424 KB Partially correct - number of queries: 5347
26 Partially correct 27 ms 2476 KB Partially correct - number of queries: 5275
27 Correct 4 ms 2128 KB Output is correct
28 Partially correct 77 ms 2508 KB Partially correct - number of queries: 8660
29 Partially correct 45 ms 2600 KB Partially correct - number of queries: 6680
30 Partially correct 62 ms 2752 KB Partially correct - number of queries: 9015
31 Correct 5 ms 2120 KB Output is correct
32 Correct 9 ms 2340 KB Output is correct
33 Correct 1 ms 976 KB Output is correct
34 Correct 26 ms 2368 KB Output is correct
35 Correct 4 ms 2256 KB Output is correct
36 Correct 14 ms 2336 KB Output is correct
37 Correct 7 ms 2152 KB Output is correct
38 Correct 3 ms 2164 KB Output is correct
39 Correct 27 ms 2476 KB Output is correct
40 Partially correct 65 ms 2604 KB Partially correct - number of queries: 7771
41 Partially correct 29 ms 2644 KB Partially correct - number of queries: 5640
42 Partially correct 20 ms 2584 KB Partially correct - number of queries: 5637
43 Partially correct 19 ms 2532 KB Partially correct - number of queries: 5138
44 Correct 28 ms 2432 KB Output is correct
45 Correct 30 ms 2432 KB Output is correct
46 Correct 5 ms 2120 KB Output is correct
47 Correct 35 ms 2400 KB Output is correct
48 Partially correct 24 ms 2584 KB Partially correct - number of queries: 6847
49 Correct 11 ms 2224 KB Output is correct
50 Partially correct 54 ms 2592 KB Partially correct - number of queries: 9075
51 Correct 32 ms 2416 KB Output is correct
52 Correct 6 ms 2120 KB Output is correct
53 Correct 3 ms 2284 KB Output is correct
54 Correct 18 ms 2536 KB Output is correct
55 Correct 3 ms 2248 KB Output is correct
56 Partially correct 39 ms 2860 KB Partially correct - number of queries: 9082
57 Partially correct 45 ms 2496 KB Partially correct - number of queries: 6756
58 Partially correct 43 ms 2512 KB Partially correct - number of queries: 6859
59 Partially correct 28 ms 2404 KB Partially correct - number of queries: 5632
60 Partially correct 20 ms 2500 KB Partially correct - number of queries: 5257
61 Correct 3 ms 2212 KB Output is correct
62 Correct 3 ms 2232 KB Output is correct
63 Correct 6 ms 2224 KB Output is correct
64 Correct 6 ms 2256 KB Output is correct
65 Correct 3 ms 2308 KB Output is correct
66 Correct 9 ms 2216 KB Output is correct
67 Correct 3 ms 2100 KB Output is correct
68 Correct 5 ms 2200 KB Output is correct
69 Correct 4 ms 2120 KB Output is correct
70 Correct 5 ms 2128 KB Output is correct
71 Partially correct 81 ms 2544 KB Partially correct - number of queries: 9308
72 Correct 11 ms 2376 KB Output is correct
73 Partially correct 82 ms 2580 KB Partially correct - number of queries: 9182
74 Partially correct 36 ms 2624 KB Partially correct - number of queries: 9239
75 Correct 7 ms 2256 KB Output is correct
76 Partially correct 51 ms 2540 KB Partially correct - number of queries: 7973
77 Partially correct 55 ms 2576 KB Partially correct - number of queries: 9197
78 Correct 8 ms 2384 KB Output is correct
79 Correct 33 ms 2552 KB Output is correct
80 Partially correct 60 ms 2600 KB Partially correct - number of queries: 9183
81 Partially correct 70 ms 2620 KB Partially correct - number of queries: 9163
82 Partially correct 58 ms 2756 KB Partially correct - number of queries: 9113
83 Correct 6 ms 2324 KB Output is correct
84 Partially correct 44 ms 2624 KB Partially correct - number of queries: 7542
85 Partially correct 80 ms 2504 KB Partially correct - number of queries: 9181
86 Correct 37 ms 2456 KB Output is correct
87 Correct 7 ms 2332 KB Output is correct
88 Partially correct 59 ms 2508 KB Partially correct - number of queries: 6443
89 Correct 40 ms 2484 KB Output is correct
90 Correct 7 ms 2256 KB Output is correct
91 Correct 36 ms 2556 KB Output is correct
92 Correct 16 ms 2340 KB Output is correct
93 Partially correct 68 ms 2572 KB Partially correct - number of queries: 7869
94 Partially correct 83 ms 2564 KB Partially correct - number of queries: 8152
95 Partially correct 48 ms 2504 KB Partially correct - number of queries: 7882
96 Partially correct 54 ms 2504 KB Partially correct - number of queries: 8105
97 Partially correct 41 ms 2504 KB Partially correct - number of queries: 7445