Submission #67191

# Submission time Handle Problem Language Result Execution time Memory
67191 2018-08-13T14:15:30 Z radoslav11 The Big Prize (IOI17_prize) C++14
90 / 100
182 ms 31420 KB
#include <bits/stdc++.h>
#include "prize.h"
//#include "Lgrader.cpp"
 
using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
 
vector<int> memo[MAXN];
int Q = 0;
bool stop;
bool dummy[MAXN];
 
vector<int> query(int i) 
{
	if(!memo[i].empty()) return memo[i];
	if(stop || dummy[i]) return vector<int>(2, 1e9);
 
	memo[i] = ask(i), Q++;
	if(Q == 10000) assert(false);
	return memo[i];
}
 
int n;
mt19937 mt(42);
 int cnt(int l, int r);
 int cnt1(int l, int r);
 
 
 
int sum(int x) { return query(x)[0]+query(x)[1];}
 int better(int l, int r)
   {
       return sum(l)>sum(r);
   }
  int abetter(int l, int r)
   {
       return sum(l)>=sum(r);
   }
 
int cnt1(int l, int r) { return query(r)[0] - query(l)[0] - better(r,l); }
int cnt(int l, int r) { return query(l)[1] - query(r)[1] - better(l,r); }
 
bool useless(int l, int r)
{
	if(abetter(l, r) && cnt(l,r) <= 0) return true;
	if(abetter(r, l) && cnt1(l,r) <= 0) return true;
	//if(query(r)[0] - query(l)[0] == 0) return true;
	return false;
}
 
void rec(int l, int r)
{
	if(r < l) return;
 
	int mid = (l + r) >> 1;
	if(query(l - 1)[0] + query(l - 1)[1] == 0) stop = 1;	
	
	if(query(r + 1)[0] + query(r + 1)[1] == 0) stop = 1;
 
	if(useless(l - 1, r + 1))
	{
		for(int i = l; i <= r; i++)
			memo[i] = query(l - 1);
		return;
	}
  /*
    if(cnt() && )
      {
      for(int i = l; i< mid;i++)dummy[i] = 1;
      for(int i = mid+1; i< r+1;i++)dummy[i] = 1;           return;
      }
   */
   	
  	if(sum(l - 1) == sum(r + 1) && cnt(l - 1, r + 1) == 1 && sum(l) > sum(mid))
          return;
  
    if(cnt(l - 1, mid) > cnt(mid, r + 1))
	{
		if(useless(l - 1, mid))
			for(int i = l; i < mid; i++)
				dummy[i] = 1;
		else
			rec(l, mid - 1);
 
		if(useless(mid, r + 1))
			for(int i = mid + 1; i <= r; i++)
				dummy[i] = 1;
		else
			rec(mid + 1, r);	
	}
	else
	{
		if(useless(mid, r + 1))
			for(int i = mid + 1; i <= r; i++)
				dummy[i] = 1;
		else
			rec(mid + 1, r);	
		
		if(useless(l - 1, mid))
			for(int i = l; i < mid; i++)
				dummy[i] = 1;
		else
			rec(l, mid - 1);
 
 
	}
}
 
int find_best(int n) 
{	
	::n = n;
	rec(1, n - 2);stop=	
1;for(int i = 0; i < n; i++)
		if(query(i)[0] + query(i)[1] == 0)
			return i;
 
	return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 25080 KB Output is correct
2 Correct 34 ms 25268 KB Output is correct
3 Correct 33 ms 25268 KB Output is correct
4 Correct 67 ms 31308 KB Output is correct
5 Correct 34 ms 31308 KB Output is correct
6 Correct 25 ms 31308 KB Output is correct
7 Correct 36 ms 31308 KB Output is correct
8 Correct 34 ms 31308 KB Output is correct
9 Correct 38 ms 31308 KB Output is correct
10 Correct 47 ms 31308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31308 KB Output is correct
2 Correct 36 ms 31308 KB Output is correct
3 Correct 33 ms 31308 KB Output is correct
4 Correct 67 ms 31420 KB Output is correct
5 Correct 35 ms 31420 KB Output is correct
6 Correct 25 ms 31420 KB Output is correct
7 Correct 35 ms 31420 KB Output is correct
8 Correct 36 ms 31420 KB Output is correct
9 Correct 38 ms 31420 KB Output is correct
10 Correct 41 ms 31420 KB Output is correct
11 Correct 48 ms 31420 KB Output is correct
12 Correct 33 ms 31420 KB Output is correct
13 Correct 62 ms 31420 KB Output is correct
14 Correct 34 ms 31420 KB Output is correct
15 Correct 53 ms 31420 KB Output is correct
16 Partially correct 119 ms 31420 KB Partially correct - number of queries: 6066
17 Partially correct 125 ms 31420 KB Partially correct - number of queries: 6010
18 Correct 100 ms 31420 KB Output is correct
19 Partially correct 101 ms 31420 KB Partially correct - number of queries: 5672
20 Correct 59 ms 31420 KB Output is correct
21 Partially correct 110 ms 31420 KB Partially correct - number of queries: 5994
22 Correct 109 ms 31420 KB Output is correct
23 Correct 36 ms 31420 KB Output is correct
24 Correct 29 ms 31420 KB Output is correct
25 Correct 70 ms 31420 KB Output is correct
26 Partially correct 106 ms 31420 KB Partially correct - number of queries: 5356
27 Correct 32 ms 31420 KB Output is correct
28 Partially correct 114 ms 31420 KB Partially correct - number of queries: 5158
29 Correct 86 ms 31420 KB Output is correct
30 Correct 73 ms 31420 KB Output is correct
31 Partially correct 126 ms 31420 KB Partially correct - number of queries: 5978
32 Correct 42 ms 31420 KB Output is correct
33 Correct 27 ms 31420 KB Output is correct
34 Partially correct 143 ms 31420 KB Partially correct - number of queries: 6073
35 Correct 41 ms 31420 KB Output is correct
36 Partially correct 105 ms 31420 KB Partially correct - number of queries: 5944
37 Correct 39 ms 31420 KB Output is correct
38 Correct 33 ms 31420 KB Output is correct
39 Partially correct 121 ms 31420 KB Partially correct - number of queries: 5940
40 Partially correct 107 ms 31420 KB Partially correct - number of queries: 5249
41 Correct 73 ms 31420 KB Output is correct
42 Correct 70 ms 31420 KB Output is correct
43 Partially correct 137 ms 31420 KB Partially correct - number of queries: 5866
44 Correct 49 ms 31420 KB Output is correct
45 Partially correct 116 ms 31420 KB Partially correct - number of queries: 5351
46 Partially correct 130 ms 31420 KB Partially correct - number of queries: 5993
47 Partially correct 119 ms 31420 KB Partially correct - number of queries: 5422
48 Correct 45 ms 31420 KB Output is correct
49 Partially correct 104 ms 31420 KB Partially correct - number of queries: 6019
50 Partially correct 86 ms 31420 KB Partially correct - number of queries: 6057
51 Partially correct 113 ms 31420 KB Partially correct - number of queries: 5994
52 Partially correct 122 ms 31420 KB Partially correct - number of queries: 5998
53 Correct 46 ms 31420 KB Output is correct
54 Partially correct 104 ms 31420 KB Partially correct - number of queries: 6001
55 Partially correct 130 ms 31420 KB Partially correct - number of queries: 5994
56 Partially correct 123 ms 31420 KB Partially correct - number of queries: 6009
57 Partially correct 122 ms 31420 KB Partially correct - number of queries: 6010
58 Partially correct 126 ms 31420 KB Partially correct - number of queries: 5982
59 Partially correct 140 ms 31420 KB Partially correct - number of queries: 6034
60 Correct 72 ms 31420 KB Output is correct
61 Correct 45 ms 31420 KB Output is correct
62 Correct 30 ms 31420 KB Output is correct
63 Correct 52 ms 31420 KB Output is correct
64 Correct 52 ms 31420 KB Output is correct
65 Correct 44 ms 31420 KB Output is correct
66 Correct 47 ms 31420 KB Output is correct
67 Correct 44 ms 31420 KB Output is correct
68 Correct 27 ms 31420 KB Output is correct
69 Correct 49 ms 31420 KB Output is correct
70 Correct 41 ms 31420 KB Output is correct
71 Partially correct 117 ms 31420 KB Partially correct - number of queries: 8577
72 Correct 35 ms 31420 KB Output is correct
73 Partially correct 133 ms 31420 KB Partially correct - number of queries: 8465
74 Partially correct 182 ms 31420 KB Partially correct - number of queries: 8513
75 Correct 39 ms 31420 KB Output is correct
76 Partially correct 109 ms 31420 KB Partially correct - number of queries: 7425
77 Partially correct 133 ms 31420 KB Partially correct - number of queries: 7351
78 Correct 33 ms 31420 KB Output is correct
79 Correct 72 ms 31420 KB Output is correct
80 Partially correct 130 ms 31420 KB Partially correct - number of queries: 7516
81 Partially correct 111 ms 31420 KB Partially correct - number of queries: 7278
82 Partially correct 116 ms 31420 KB Partially correct - number of queries: 7285
83 Correct 30 ms 31420 KB Output is correct
84 Partially correct 104 ms 31420 KB Partially correct - number of queries: 6150
85 Partially correct 102 ms 31420 KB Partially correct - number of queries: 7382
86 Correct 33 ms 31420 KB Output is correct
87 Correct 34 ms 31420 KB Output is correct
88 Correct 29 ms 31420 KB Output is correct
89 Correct 32 ms 31420 KB Output is correct
90 Correct 40 ms 31420 KB Output is correct
91 Correct 39 ms 31420 KB Output is correct
92 Correct 57 ms 31420 KB Output is correct
93 Correct 36 ms 31420 KB Output is correct
94 Correct 51 ms 31420 KB Output is correct
95 Correct 39 ms 31420 KB Output is correct
96 Correct 35 ms 31420 KB Output is correct
97 Correct 42 ms 31420 KB Output is correct