Submission #72820

# Submission time Handle Problem Language Result Execution time Memory
72820 2018-08-27T03:38:38 Z funcsr The Big Prize (IOI17_prize) C++17
20 / 100
68 ms 3900 KB
#include "prize.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
#define rep(i,n)for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define _1 first
#define _2 second
#define INF 1145141919
typedef pair<int, int> P;
mt19937 mt_rand(114514);
int mp = 0;
P cache[200000];
int Q=0;
P query(int x) {
  if (cache[x] != P(-1, -1)) return cache[x];
  Q++;
  //if(Q%100==0)cout<<"Q="<<Q<<"\n";
  vector<int> ret = ask(x);
  return cache[x] = {ret[0], ret[1]};
}

int solve(int l, int r, int num, int left) {
  if (num <= 0) return -1;
  //cout<<"solve("<<l<<","<<r<<", num="<<num<<")\n";
  int mid = (l+r)/2;
  for (; mid>=l; mid--) {
    P ret = query(mid);
    if (ret._1+ret._2 == 0) return mid;
    if (ret._1+ret._2 != mp) continue;
    if (mid > l) {
      int o = solve(l, mid-1, ret._1-left, left);
      if (o != -1) return o;
    }
    if (mid < r) {
      int o = solve(mid+1, r, num-(ret._1-left), ret._1);
      if (o != -1) return o;
    }
    break;
  }
  return -1;
}

int find_best(int N) {
  rep(i, N) cache[i] = P(-1, -1);
  rep(i, 30) {
    P ret = query(mt_rand()%N);
    mp = max(mp, ret._1+ret._2);
  }
  //cout<<"mp="<<mp<<"\n";
  assert(mp < 500);
  int r = solve(0, N-1, mp, 0);
  assert(r != -1);
  return r;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1836 KB Output is correct
2 Correct 6 ms 1976 KB Output is correct
3 Correct 5 ms 1976 KB Output is correct
4 Correct 5 ms 1976 KB Output is correct
5 Correct 5 ms 2008 KB Output is correct
6 Correct 6 ms 2136 KB Output is correct
7 Correct 5 ms 2136 KB Output is correct
8 Correct 4 ms 2136 KB Output is correct
9 Correct 4 ms 2136 KB Output is correct
10 Correct 5 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2136 KB Output is correct
2 Correct 5 ms 2136 KB Output is correct
3 Correct 5 ms 2136 KB Output is correct
4 Correct 4 ms 2136 KB Output is correct
5 Correct 5 ms 2136 KB Output is correct
6 Correct 4 ms 2136 KB Output is correct
7 Correct 5 ms 2136 KB Output is correct
8 Correct 4 ms 2136 KB Output is correct
9 Correct 4 ms 2136 KB Output is correct
10 Correct 5 ms 2136 KB Output is correct
11 Correct 6 ms 2136 KB Output is correct
12 Correct 5 ms 2136 KB Output is correct
13 Correct 5 ms 2136 KB Output is correct
14 Correct 6 ms 2136 KB Output is correct
15 Correct 6 ms 2136 KB Output is correct
16 Correct 37 ms 2136 KB Output is correct
17 Correct 5 ms 2136 KB Output is correct
18 Correct 51 ms 2136 KB Output is correct
19 Correct 4 ms 2136 KB Output is correct
20 Correct 12 ms 2136 KB Output is correct
21 Correct 18 ms 2136 KB Output is correct
22 Correct 9 ms 2136 KB Output is correct
23 Correct 5 ms 2136 KB Output is correct
24 Correct 5 ms 2136 KB Output is correct
25 Correct 13 ms 2136 KB Output is correct
26 Correct 22 ms 2136 KB Output is correct
27 Correct 5 ms 2136 KB Output is correct
28 Correct 46 ms 2136 KB Output is correct
29 Correct 39 ms 2136 KB Output is correct
30 Correct 68 ms 2136 KB Output is correct
31 Correct 4 ms 2136 KB Output is correct
32 Correct 7 ms 2136 KB Output is correct
33 Correct 2 ms 2136 KB Output is correct
34 Correct 26 ms 2136 KB Output is correct
35 Correct 6 ms 2136 KB Output is correct
36 Correct 15 ms 2136 KB Output is correct
37 Correct 7 ms 2136 KB Output is correct
38 Correct 4 ms 2136 KB Output is correct
39 Correct 28 ms 2136 KB Output is correct
40 Correct 67 ms 2136 KB Output is correct
41 Correct 34 ms 2136 KB Output is correct
42 Correct 28 ms 2136 KB Output is correct
43 Correct 29 ms 2136 KB Output is correct
44 Correct 19 ms 2136 KB Output is correct
45 Correct 15 ms 2136 KB Output is correct
46 Correct 6 ms 2136 KB Output is correct
47 Correct 20 ms 2136 KB Output is correct
48 Correct 31 ms 2136 KB Output is correct
49 Correct 8 ms 2136 KB Output is correct
50 Correct 32 ms 2136 KB Output is correct
51 Correct 12 ms 2136 KB Output is correct
52 Correct 5 ms 2136 KB Output is correct
53 Correct 5 ms 2136 KB Output is correct
54 Correct 20 ms 2136 KB Output is correct
55 Correct 4 ms 2136 KB Output is correct
56 Correct 35 ms 2136 KB Output is correct
57 Correct 59 ms 2136 KB Output is correct
58 Correct 20 ms 2136 KB Output is correct
59 Correct 23 ms 2136 KB Output is correct
60 Correct 31 ms 2136 KB Output is correct
61 Correct 5 ms 2136 KB Output is correct
62 Correct 4 ms 2136 KB Output is correct
63 Correct 4 ms 2136 KB Output is correct
64 Correct 5 ms 2136 KB Output is correct
65 Runtime error 8 ms 3900 KB Execution killed with signal 11 (could be triggered by violating memory limits)
66 Halted 0 ms 0 KB -