Submission #1026346

# Submission time Handle Problem Language Result Execution time Memory
1026346 2024-07-18T00:58:20 Z huutuan The Big Prize (IOI17_prize) C++14
20 / 100
42 ms 10700 KB
#include "prize.h"

#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int> mem[200000];

vector<int> Ask(int i){
   if (mem[i].size()) return mem[i];
   return mem[i]=ask(i);
}

int find_best(int n) {
   for (int i=0; i<n; ++i) mem[i].clear();
   // if (n<=5000){
   //    for (int i=0; i<n; ++i){
   //       auto tmp=Ask(i);
   //       if (tmp[0]+tmp[1]==0) return i;
   //    }
   //    return -1;
   // }
   int m=n;
   int mx=0;
   while (m>1){
      m=(int)sqrt(m);
      mx+=m;
   }
   mx=min(mx, 200);
   vector<pair<int, int>> v(mx);
   for (int i=0; i<mx; ++i){
      auto tmp=Ask(i);
      v[i]={tmp[0], tmp[1]};
      if (tmp[0]+tmp[1]==0) return i;
   }
   int cnt=0;
   for (auto &i:v) cnt=max(cnt, i.first+i.second);
   ordered_set<int> id;
   vector<int> st;
   for (int i=0; i<mx; ++i) if (v[i].first+v[i].second!=cnt) id.insert(i);
   for (int i=mx; i<n; ++i) st.push_back(i);
   auto solve=[&](auto &&self, vector<int> pos, int cc){
      if (!cc || pos.empty()) return;
      int mid=((int)pos.size()-1)/2;
      vector<int> posl, posr;
      for (int j:pos){
         if (j<pos[mid]) posl.push_back(j);
         if (j>pos[mid]) posr.push_back(j);
      }
      auto tmp=Ask(pos[mid]);
      if (tmp[0]+tmp[1]!=cnt){
         id.insert(pos[mid]);
         pos.erase(pos.begin()+mid);
         self(self, pos, cc-1);
      }else{
         int cl=tmp[0]-id.order_of_key(pos[mid]);
         int cr=cc-cl;
         self(self, posl, cl);
         self(self, posr, cr);
      }
   };
   solve(solve, st, cnt-(int)id.size());
   for (int i:id){
      auto tmp=Ask(i);
      if (tmp[0]+tmp[1]==0) return i;
   }
   return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8908 KB Output is correct
2 Correct 6 ms 8908 KB Output is correct
3 Correct 5 ms 9164 KB Output is correct
4 Correct 7 ms 9160 KB Output is correct
5 Correct 7 ms 9164 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 5 ms 8992 KB Output is correct
8 Correct 5 ms 9164 KB Output is correct
9 Correct 8 ms 8908 KB Output is correct
10 Correct 9 ms 9164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8908 KB Output is correct
2 Correct 6 ms 8908 KB Output is correct
3 Correct 5 ms 9164 KB Output is correct
4 Correct 5 ms 9164 KB Output is correct
5 Correct 6 ms 8908 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 6 ms 9164 KB Output is correct
8 Correct 6 ms 9164 KB Output is correct
9 Correct 6 ms 9084 KB Output is correct
10 Correct 5 ms 9164 KB Output is correct
11 Correct 10 ms 9164 KB Output is correct
12 Correct 9 ms 9164 KB Output is correct
13 Correct 13 ms 9164 KB Output is correct
14 Correct 8 ms 5872 KB Output is correct
15 Correct 26 ms 9164 KB Output is correct
16 Correct 32 ms 9468 KB Output is correct
17 Correct 39 ms 9412 KB Output is correct
18 Correct 27 ms 9420 KB Output is correct
19 Correct 28 ms 9164 KB Output is correct
20 Correct 16 ms 7372 KB Output is correct
21 Correct 35 ms 9276 KB Output is correct
22 Correct 25 ms 9204 KB Output is correct
23 Correct 9 ms 9164 KB Output is correct
24 Correct 13 ms 9168 KB Output is correct
25 Correct 23 ms 9164 KB Output is correct
26 Correct 41 ms 9164 KB Output is correct
27 Correct 8 ms 9164 KB Output is correct
28 Correct 28 ms 9216 KB Output is correct
29 Correct 24 ms 9252 KB Output is correct
30 Correct 38 ms 9216 KB Output is correct
31 Correct 30 ms 9164 KB Output is correct
32 Correct 10 ms 9164 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Correct 28 ms 9164 KB Output is correct
35 Correct 8 ms 9164 KB Output is correct
36 Correct 42 ms 9360 KB Output is correct
37 Correct 14 ms 9164 KB Output is correct
38 Correct 9 ms 9164 KB Output is correct
39 Correct 32 ms 9212 KB Output is correct
40 Correct 32 ms 9704 KB Output is correct
41 Correct 29 ms 9156 KB Output is correct
42 Correct 42 ms 9704 KB Output is correct
43 Correct 26 ms 9480 KB Output is correct
44 Correct 26 ms 9256 KB Output is correct
45 Correct 24 ms 9164 KB Output is correct
46 Correct 27 ms 9408 KB Output is correct
47 Correct 32 ms 9464 KB Output is correct
48 Correct 37 ms 9164 KB Output is correct
49 Correct 33 ms 9420 KB Output is correct
50 Correct 36 ms 9464 KB Output is correct
51 Correct 36 ms 9428 KB Output is correct
52 Correct 27 ms 9164 KB Output is correct
53 Correct 7 ms 9164 KB Output is correct
54 Correct 41 ms 9684 KB Output is correct
55 Correct 34 ms 9436 KB Output is correct
56 Correct 27 ms 9420 KB Output is correct
57 Correct 34 ms 9420 KB Output is correct
58 Correct 37 ms 9504 KB Output is correct
59 Correct 31 ms 9524 KB Output is correct
60 Correct 26 ms 9208 KB Output is correct
61 Correct 7 ms 9164 KB Output is correct
62 Correct 7 ms 8924 KB Output is correct
63 Correct 9 ms 9164 KB Output is correct
64 Correct 7 ms 9164 KB Output is correct
65 Correct 6 ms 9164 KB Output is correct
66 Correct 12 ms 10700 KB Output is correct
67 Correct 9 ms 10700 KB Output is correct
68 Incorrect 5 ms 8652 KB Integer -1 violates the range [0, 199999]
69 Halted 0 ms 0 KB -