Submission #1113346

# Submission time Handle Problem Language Result Execution time Memory
1113346 2024-11-16T12:11:46 Z epicci23 The Big Prize (IOI17_prize) C++17
20 / 100
181 ms 1792 KB
#include "bits/stdc++.h"
#include "prize.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;

const int S = 100;
const int S2 = 20;

int suf = -1;
vector<int> Cache={-1,-1};
map<int,vector<int>> dp;

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

int ask_all(int l,int r){
  for(int i=l;i<=r;i++){
    vector<int> x = Ask(i);
    if(x[0]+x[1]==0) return i;
    if(x[1]==suf) Cache=x;
    else suf--;
  }
  return -23;
}

int Learn(int l,int r){
  if(l>r) return -1;
  if(l==r){
    auto u = Ask(l);
    if(u[0]+u[1]==0) return l;
    if(u[1]==suf) Cache=u;
    else suf--;
    return -1;
  }
  int BL = (int)sqrtl(r-l+1);
  auto u = Ask(l+BL);
  if(u[0]+u[1]==0) return l+BL;
  if(u[1]==suf) return Learn(l+BL+1,r);
  int lf = Learn(l,l+BL-1);
  if(lf!=-1) return lf;
  if(u[1]==suf) Cache=u;
  else suf--;
  return Learn(l+BL+1,r);
}

int find_best(int n){
  if(n<=1000) return ask_all(0,n-1);
  for(int i=0;i<=500;i++){
    vector<int> x = Ask(i);
    if(x[0]+x[1]==0) return i;
    if(x[0]+x[1]>=Cache[0]+Cache[1]){
      Cache=x;
      suf=Cache[1];
    }
    else suf--;
  }
  return Learn(501,n-1);
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 336 KB Output is correct
2 Correct 14 ms 980 KB Output is correct
3 Correct 12 ms 592 KB Output is correct
4 Correct 25 ms 648 KB Output is correct
5 Correct 15 ms 608 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 14 ms 592 KB Output is correct
8 Correct 14 ms 336 KB Output is correct
9 Correct 15 ms 768 KB Output is correct
10 Correct 24 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 448 KB Output is correct
2 Correct 15 ms 1208 KB Output is correct
3 Correct 13 ms 496 KB Output is correct
4 Correct 28 ms 592 KB Output is correct
5 Correct 13 ms 968 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Correct 15 ms 508 KB Output is correct
8 Correct 15 ms 336 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 29 ms 620 KB Output is correct
11 Correct 25 ms 540 KB Output is correct
12 Correct 10 ms 336 KB Output is correct
13 Correct 41 ms 584 KB Output is correct
14 Correct 18 ms 592 KB Output is correct
15 Correct 56 ms 840 KB Output is correct
16 Incorrect 181 ms 1792 KB Incorrect
17 Halted 0 ms 0 KB -