Submission #1113628

# Submission time Handle Problem Language Result Execution time Memory
1113628 2024-11-16T21:00:54 Z epicci23 The Big Prize (IOI17_prize) C++17
20 / 100
174 ms 1548 KB
#include "bits/stdc++.h"
#include "prize.h"
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
 
const int BL = 10000;

int suf = -1, ans = -1;

map<int,vector<int>> dp;
vector<bool> mark;

vector<int> Ask(int i){
  if( dp.count(i) ) return dp[i];
  return dp[i] = ask(i);
}
 
void Learn(int l,int r){
  if(l > r || ans != -1) return;
  if(l == r){
    mark[l] = 1;
    suf--;
    return;
  }
  
  auto w = Ask(r);
  if(w[1] == suf) return;
  if(w[0] + w[1] == 0){
    ans = r;
    return;
  }
  
  int mid = (l + r) / 2;
  auto u = Ask(mid);
  if(u[0] + u[1] == 0){
    ans = mid;
    return;
  }

  if(u[1] == suf){
    Learn(mid + 1, r - 1);
    if(w[1] < suf) suf--;
    return;
  }
  
  Learn(l, mid - 1);
  if(u[1] < suf) suf--;
  if(ans != -1 || w[1] == suf) return;

  Learn(mid + 1, r - 1);
  if(w[1] < suf) suf--;
  return;
}
 
int find_best(int n){
  mark.assign(n,0);
  int art = 0, i = 0, mx = -1;
  for(; i <= 475; i++){
  	if(art == 5) break;
    vector<int> x = Ask(i);
    if(x[0] + x[1] == 0) return i;
    if(x[0] + x[1] > mx) art++;
    if(x[0] + x[1] >= mx){
      mx = x[0] + x[1];
      suf = x[1];
    }
    else suf--;
  }

  Learn(i, n - 1);

  if(ans != -1) return ans;

  for(i = 0; i < n; i++){
    if(mark[i] == 0) continue;
    vector<int> Cand = Ask(i);
    if(Cand[0] + Cand[1] == 0) return i;
  }

  assert(0);
  return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 336 KB Output is correct
2 Correct 8 ms 336 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 8 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 10 ms 1012 KB Output is correct
8 Correct 7 ms 336 KB Output is correct
9 Correct 11 ms 336 KB Output is correct
10 Correct 12 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 592 KB Output is correct
2 Correct 10 ms 336 KB Output is correct
3 Correct 7 ms 336 KB Output is correct
4 Correct 9 ms 728 KB Output is correct
5 Correct 11 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 11 ms 336 KB Output is correct
8 Correct 10 ms 336 KB Output is correct
9 Correct 9 ms 336 KB Output is correct
10 Correct 9 ms 592 KB Output is correct
11 Incorrect 174 ms 1548 KB Incorrect
12 Halted 0 ms 0 KB -