Submission #1113326

# Submission time Handle Problem Language Result Execution time Memory
1113326 2024-11-16T11:35:08 Z epicci23 The Big Prize (IOI17_prize) C++17
20 / 100
207 ms 1656 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 = 30;

int L = -1;
vector<int> Cache;
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[0]+x[1]==Cache[0]+Cache[1]) Cache=x;
  }
  return -23;
}

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(L==-1){
      L=i;
      Cache=x;
    }
    else if(x[0]+x[1]>Cache[0]+Cache[1]){
      L=i;
      Cache=x;
    }
    else if(x[0]+x[1]==Cache[0]+Cache[1]){
      L=i;
      Cache=x;
    }
  }
  
  while(L+S<n){
    vector<int> x = Ask(L+S);
    if(x[0]+x[1]==0) return L+S;
    if(x[0]+x[1]==Cache[0]+Cache[1] && Cache[1]==x[1]){
      L+=S;
      Cache=x;
      continue;
    }
    int p = L;
    while(p+S2<L+S){
      p+=S2;
      vector<int> u = Ask(p);
      if(u[0]+u[1]==0) return p;
      if(u[0]+u[1]==Cache[0]+Cache[1] && Cache[1]==u[1]) Cache=u;
      else{
        int xd = ask_all(p-S2+1,p-1);
        if(xd!=-23) return xd;
      }
    }
    int xd = ask_all(p+1,L+S-1);
    if(xd!=-23) return xd;
    L+=S;
    if(x[0]+x[1]==Cache[0]+Cache[1]) Cache=x;
  }
  return ask_all(L+1,n-1);
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 456 KB Output is correct
2 Correct 26 ms 840 KB Output is correct
3 Correct 23 ms 812 KB Output is correct
4 Correct 38 ms 592 KB Output is correct
5 Correct 22 ms 772 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 26 ms 708 KB Output is correct
8 Correct 20 ms 704 KB Output is correct
9 Correct 28 ms 696 KB Output is correct
10 Correct 49 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 600 KB Output is correct
2 Correct 32 ms 584 KB Output is correct
3 Correct 27 ms 756 KB Output is correct
4 Correct 52 ms 848 KB Output is correct
5 Correct 25 ms 1488 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 26 ms 840 KB Output is correct
8 Correct 27 ms 968 KB Output is correct
9 Correct 22 ms 472 KB Output is correct
10 Correct 51 ms 472 KB Output is correct
11 Correct 31 ms 764 KB Output is correct
12 Correct 10 ms 336 KB Output is correct
13 Correct 60 ms 664 KB Output is correct
14 Correct 18 ms 908 KB Output is correct
15 Correct 75 ms 584 KB Output is correct
16 Incorrect 207 ms 1656 KB Incorrect
17 Halted 0 ms 0 KB -