Submission #1094680

# Submission time Handle Problem Language Result Execution time Memory
1094680 2024-09-30T09:26:17 Z huyngo The Big Prize (IOI17_prize) C++17
20 / 100
3 ms 5204 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;


int find_best(int n) {
	vector<vector<int>> info(n);
	map<int, int> found;
	auto get = [&](int i) -> vector<int> {
		if (info[i].size())
			return info[i];
		info[i] = ask(i);
		found[info[i][0] + info[i][1]]++;
		// for (int i = 0; i < n; ++i)
		// 	cerr << info[i].size() << ' ';
		// cerr << '\n';
		return info[i];
		};

	auto findNext = [&](int l, int r, int cur) -> int {
		int lo = l, hi = r, x = -1;
		while (lo <= hi) {
			int md = (lo + hi) / 2;
			if (get(md)[0] + get(md)[1] > cur) {
				if (get(md)[0] <= found[cur]) {
					x = md;
					lo = md + 1;
				}
				else {
					hi = md - 1;
				}
			}
			else if (get(md)[0] + get(md)[1] < cur) {
				if (get(md)[0] == 0)
					return md;
				else
					hi = md - 1;
			}
			else {
				if (get(md)[0] == 0) {
					found[cur] += get(md)[1] - get(l - 1)[1] - 1;
					return md;
				}
				else {
					hi = md - 1;
				}
			}
		}
		return x;
		};

	found[0] = 0;
	int l = 0, r = n - 1;
	get(0);
	while (!found[0]) {
		l = findNext(l + 1, r, get(l)[0] + get(l)[1]);
		// cerr << l << '\n';
		if (l == -1) break;
	}
	for (int i = 0; i < n; ++i) {
		if (info[i].size() && info[i][0] + info[i][1] == 0)
			return i;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5204 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 3 ms 5036 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 3 ms 4952 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 3 ms 4952 KB Output is correct
9 Correct 2 ms 4952 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 3 ms 4952 KB Output is correct
10 Correct 3 ms 4952 KB Output is correct
11 Incorrect 3 ms 4952 KB answer is not correct
12 Halted 0 ms 0 KB -