Submission #1113318

# Submission time Handle Problem Language Result Execution time Memory
1113318 2024-11-16T11:16:16 Z epicci23 The Big Prize (IOI17_prize) C++17
20 / 100
1000 ms 344 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;
const int HM = 10000;

int cnt=0;

int ask_all(int l,int r){
  for(int i=l;i<=r;i++){
    cnt++;
    if(cnt>HM) while(1){}
    auto x = ask(i);
    if(x[0]+x[1]==0) return i;
  }
  return -23;
}

int find_best(int n){
  if(n<=1000) return ask_all(0,n-1);
  int L = -1;
  vector<int> Cache;
  for(int i=0;i<500;i++){
    cnt++;
    if(cnt>HM) while(1){}
    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;
    }
  }
  
  while(L+S<n){
  	cnt++;
    if(cnt>HM) while(1){}
    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;
      continue;
    }
    int p = L;
    while(p+S2<L+S){
      p+=S2;
      cnt++;
      if(cnt>HM) while(1){}
      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]) continue;
      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;
  }
  return ask_all(L+1,n-1);
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 336 KB Output is correct
2 Correct 21 ms 336 KB Output is correct
3 Correct 22 ms 336 KB Output is correct
4 Correct 39 ms 336 KB Output is correct
5 Correct 21 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 23 ms 336 KB Output is correct
8 Correct 22 ms 336 KB Output is correct
9 Correct 20 ms 336 KB Output is correct
10 Correct 41 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 336 KB Output is correct
2 Correct 24 ms 336 KB Output is correct
3 Correct 23 ms 336 KB Output is correct
4 Correct 38 ms 336 KB Output is correct
5 Correct 25 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 21 ms 336 KB Output is correct
8 Correct 20 ms 336 KB Output is correct
9 Correct 25 ms 336 KB Output is correct
10 Correct 38 ms 336 KB Output is correct
11 Execution timed out 3051 ms 336 KB Time limit exceeded
12 Halted 0 ms 0 KB -