Submission #52383

# Submission time Handle Problem Language Result Execution time Memory
52383 2018-06-25T17:18:32 Z WLZ The Big Prize (IOI17_prize) C++17
20 / 100
72 ms 644 KB
#include "prize.h"
#include <vector>
#include <queue>

int find_best(int n) {
    std::queue< std::pair<int, int> > q;
    std::vector<bool> asked(n, false);
    q.emplace(0, n - 1);
    while (!q.empty()) {
        std::pair<int, int> cur = q.front(); q.pop();
        int mid = (cur.first + cur.second) / 2;
        if (asked[mid]) continue;
        std::vector<int> v = ask(mid);
        asked[mid] = true;
        if (!v[0] && !v[1]) return mid;
        if (v[0] > v[1]) {
            if (v[0]) q.emplace(cur.first, mid - 1);
            if (v[1]) q.emplace(mid + 1, cur.second);
        } else {
            if (v[1]) q.emplace(mid + 1, cur.second);
            if (v[0]) q.emplace(cur.first, mid - 1);
        }
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 576 KB Output is correct
5 Correct 2 ms 576 KB Output is correct
6 Correct 2 ms 576 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 576 KB Output is correct
9 Correct 2 ms 576 KB Output is correct
10 Correct 2 ms 576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 576 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
3 Correct 2 ms 576 KB Output is correct
4 Correct 2 ms 576 KB Output is correct
5 Correct 2 ms 576 KB Output is correct
6 Correct 2 ms 576 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 4 ms 576 KB Output is correct
9 Correct 3 ms 576 KB Output is correct
10 Correct 2 ms 576 KB Output is correct
11 Incorrect 72 ms 644 KB Incorrect
12 Halted 0 ms 0 KB -