Submission #81596

# Submission time Handle Problem Language Result Execution time Memory
81596 2018-10-25T13:50:32 Z polyfish The Big Prize (IOI17_prize) C++14
20 / 100
76 ms 1248 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

map<int, pair<int, int> > asked;
vector<int> pos;

int left_val(int x) {
    if (!asked.count(x)) {
        vector<int> tmp = ask(x);
        asked[x] = make_pair(tmp[0], tmp[1]);
    }
    return asked[x].first;
}

int right_val(int x) {
    if (!asked.count(x)) {
        vector<int> tmp = ask(x);
        asked[x] = make_pair(tmp[0], tmp[1]);
    }
    return asked[x].second;
}

void find_pos(int l, int r, int nPos, int all) {
    if (l>r || nPos==0)
        return;
    int mid = (l + r) / 2;
    int tmp = mid;
    for (; mid>=l; --mid) {
        if (left_val(mid)+right_val(mid)==all)
            break;
        pos.push_back(mid);
    }
    if (mid>0)
        find_pos(l, mid-1, left_val(mid), all);
    if (tmp+1<=r)
        find_pos(tmp+1, r, nPos - left_val(tmp+1), all);
}

int find_best(int n) {
    int l = -1, max_hist = 0;
    for (int i=0; i<min(n, 500); ++i) {
        if (left_val(i)+right_val(i)>max_hist) {
            max_hist = left_val(i) + right_val(i);
            l = i;
        }
    }
    find_pos(l, n-1, right_val(l), left_val(l) + right_val(l));
    for (auto v : pos) {
        if (left_val(v) + right_val(v) == 0)
            return v;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 400 KB Output is correct
2 Correct 6 ms 400 KB Output is correct
3 Correct 4 ms 424 KB Output is correct
4 Correct 5 ms 424 KB Output is correct
5 Correct 4 ms 500 KB Output is correct
6 Correct 6 ms 500 KB Output is correct
7 Correct 4 ms 500 KB Output is correct
8 Correct 7 ms 500 KB Output is correct
9 Correct 5 ms 500 KB Output is correct
10 Correct 6 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 552 KB Output is correct
2 Correct 5 ms 556 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 5 ms 596 KB Output is correct
5 Correct 5 ms 596 KB Output is correct
6 Correct 6 ms 596 KB Output is correct
7 Correct 7 ms 596 KB Output is correct
8 Correct 5 ms 596 KB Output is correct
9 Correct 4 ms 596 KB Output is correct
10 Correct 5 ms 596 KB Output is correct
11 Partially correct 53 ms 948 KB Partially correct - number of queries: 7424
12 Partially correct 51 ms 948 KB Partially correct - number of queries: 7378
13 Partially correct 39 ms 1020 KB Partially correct - number of queries: 7416
14 Partially correct 45 ms 1020 KB Partially correct - number of queries: 5392
15 Incorrect 76 ms 1248 KB Incorrect
16 Halted 0 ms 0 KB -