Submission #54021

# Submission time Handle Problem Language Result Execution time Memory
54021 2018-07-02T08:30:39 Z chpipis The Big Prize (IOI17_prize) C++11
20 / 100
86 ms 1616 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;

int num_q;
map<int, vi> memo;

vi query(int x) {
    if (memo.count(x)) return memo[x];
    num_q++;
    vi ret = ask(x);
    return memo[x] = ret;
}

int find_best(int n) {
    memo.clear();
    num_q = 0;
    for (int i = 0, j; i < n; i = j + 1) {
        if (i == n - 1) return i;
        j = i;
        vi cur = query(i);
        if (cur[0] + cur[1] == 0) return i;
        int lo = i + 1, hi = n - 1;
        while (lo <= hi) {
            int mid = (lo + hi) >> 1;
            vi now = query(mid);
            if (now[0] + now[1] == 0) return mid;
            if (now == cur) {
                lo = mid + 1;
                j = mid;
            } else {
                hi = mid - 1;
            }
        }
    }
}



Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 288 KB Output is correct
2 Correct 3 ms 436 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 3 ms 544 KB Output is correct
10 Correct 2 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 560 KB Output is correct
2 Correct 3 ms 560 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 3 ms 560 KB Output is correct
5 Correct 3 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 3 ms 568 KB Output is correct
11 Correct 7 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 11 ms 572 KB Output is correct
14 Correct 6 ms 700 KB Output is correct
15 Correct 13 ms 792 KB Output is correct
16 Incorrect 86 ms 1616 KB Incorrect
17 Halted 0 ms 0 KB -