Submission #43132

# Submission time Handle Problem Language Result Execution time Memory
43132 2018-03-09T10:12:22 Z RayaBurong25_1 The Big Prize (IOI17_prize) C++14
20 / 100
19 ms 4364 KB
#include "prize.h"
#include <stdio.h>
#include <vector>
#include <algorithm>
int L[200005], R[200005];
int V[200005];
int min(int a, int b)
{
	return (a < b)?a:b;
}
int max(int a, int b)
{
	return (a > b)?a:b;
}
int find_best(int n) {
	int i;
	for (i = 0; i < n; i++)
		L[i] = -1;
	int mn, md, mx;
	//first sig
	std::vector<int> r;
	r = ask(0);
	L[0] = r[0];
	R[0] = r[1];
	if (R[0] == 0)
		return 0;
	r = ask(n - 1);
	L[n - 1] = r[0];
	R[n - 1] = r[1];
	if (L[n - 1] == 0)
		return n - 1;
	int sigl = 0, sigr = n - 1;
	while (sigl < sigr)
	{
		mn = 0;
		mx = sigr;
		while (mx != mn)
		{
			if (mx - mn == 1)
			{
				sigr = mn;
				break;
			}
			md = (mn + mx)/2;
			if (L[md] == -1)
			{
				r = ask(md);
				L[md] = r[0];
				R[md] = r[1];
			}
			if (L[md] == L[sigr] && R[md] == R[sigr])
				mx = md;
			else
				mn = md;
		}
		if (L[sigr] == -1)
		{
			r = ask(sigr);
			L[sigr] = r[0];
			R[sigr] = r[1];
		}
		if (L[sigr] == 0 && R[sigr] == 0)
			return sigr;
		// printf("sigl %d sigr %d\n", sigl, sigr);
		mn = sigl;
		mx = n - 1;
		while (mx != mn)
		{
			if (mx - mn == 1)
			{
				sigl = mx;
				break;
			}
			md = (mn + mx)/2;
			if (L[md] == -1)
			{
				r = ask(md);
				L[md] = r[0];
				R[md] = r[1];
			}
			if (L[md] == L[sigl] && R[md] == R[sigl])
				mn = md;
			else
				mx = md;
		}
		if (L[sigl] == -1)
		{
			r = ask(sigl);
			L[sigl] = r[0];
			R[sigl] = r[1];
		}
		if (L[sigl] == 0 && R[sigl] == 0)
			return sigl;
	}
	if (sigl == sigr)
		return sigl;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:97:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4364 KB Output is correct
2 Correct 1 ms 4364 KB Output is correct
3 Correct 1 ms 4364 KB Output is correct
4 Correct 1 ms 4364 KB Output is correct
5 Correct 1 ms 4364 KB Output is correct
6 Correct 1 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 1 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 1 ms 4364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 1 ms 4364 KB Output is correct
4 Correct 1 ms 4364 KB Output is correct
5 Correct 1 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 1 ms 4364 KB Output is correct
8 Correct 1 ms 4364 KB Output is correct
9 Correct 1 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
11 Correct 4 ms 4364 KB Output is correct
12 Correct 1 ms 4364 KB Output is correct
13 Correct 1 ms 4364 KB Output is correct
14 Correct 1 ms 4364 KB Output is correct
15 Correct 11 ms 4364 KB Output is correct
16 Correct 3 ms 4364 KB Output is correct
17 Correct 2 ms 4364 KB Output is correct
18 Correct 1 ms 4364 KB Output is correct
19 Correct 0 ms 4364 KB Output is correct
20 Partially correct 10 ms 4364 KB Partially correct - number of queries: 7146
21 Partially correct 16 ms 4364 KB Partially correct - number of queries: 9776
22 Correct 1 ms 4364 KB Output is correct
23 Correct 1 ms 4364 KB Output is correct
24 Correct 1 ms 4364 KB Output is correct
25 Incorrect 19 ms 4364 KB Incorrect
26 Halted 0 ms 0 KB -