Submission #64608

# Submission time Handle Problem Language Result Execution time Memory
64608 2018-08-05T04:35:15 Z nvmdava The Big Prize (IOI17_prize) C++17
0 / 100
13 ms 10100 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> ans[200001];
map<int, set<int> > v;
int L, R;
int find_best(int n) {
	L = 0;
	R = n - 1;
	queue<pair<int, int> > q;
	q.push(make_pair(L, R));
	int l, r, m;
	while(!q.empty()){
		l = q.front().first;
		r = q.front().second;
		q.pop();
		if(L > r ||  l > R || l > r){
			continue;
		}
		m = (l + r) >> 1;
		ans[m] = ask(m);
		if(ans[m][0] + ans[m][1] == 0){
			return m;
		}
		auto it = v.find(ans[m][0] + ans[m][1]);
		it -> second.insert(m);
		auto loc = it -> second.find(m);
		bool in = 0;
		auto tmp = loc;
		while(tmp != it -> second.begin()){
			tmp--;
			if(ans[m][0] != ans[*tmp][0]){
				in = 1;
				tmp++;
				q.push(make_pair(l, *tmp));
				break;
			}
		}
		if(in == 0){
			q.push(make_pair(l, *(it->second.begin())));
		} else {
			in = 0;
		}
		
		tmp = loc;
		while(tmp != it -> second.end()){
			if(ans[m][0] != ans[*tmp][0]){
				in = 1;
				tmp--;
				q.push(make_pair(*tmp, r));
				break;
			}
			tmp++;
		}
		if(in == 0){
			q.push(make_pair(*(it->second.end()--), r));
		}
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 9848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 10100 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -