Submission #289205

#TimeUsernameProblemLanguageResultExecution timeMemory
289205JoMeeThe Big Prize (IOI17_prize)C++17
Compilation error
0 ms0 KiB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;
int res = -1;
int c = 0;

void q(pair<int,vector<int> > l, pair<int,vector<int> > r){
	if(l.first + 1 == r.first)return;
	if(res != -1)return;
	int m = (l.first+r.first)/2;
	if(m == l.first)return;
	int sz1,sz2;
	sz1 = l.second[0]+l.second[1];
	sz1 = r.second[0]+r.second[1];
	if(l.second[1] == r.second[1] && sz1 == sz2)return;
	
	c++;
	if(c == 11999)while(true)
	vector<int> ans = ask(m);

	if(ans[0]+ans[1] == 0){
		res = m;
		return;
	}
	if(ans[0] > 0){
		q(l,make_pair(m,ans));
	}
	if(ans[1] > 0){
		q(make_pair(m,ans),r);
	}
}
int find_best(int n) {
	vector<int> a1 = ask(0);
	if(a1[0] + a1[1] == 0)res = 0;
	vector<int> a2 = ask(n-1);
	if(a2[0] + a2[1] == 0)res = n-1;
	q(make_pair(0,a1),make_pair(n-1,a2));
	return res;
}

Compilation message (stderr)

prize.cpp: In function 'void q(std::pair<int, std::vector<int> >, std::pair<int, std::vector<int> >)':
prize.cpp:22:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |  if(ans[0]+ans[1] == 0){
      |     ^~~
      |     abs
prize.cpp:26:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |  if(ans[0] > 0){
      |     ^~~
      |     abs
prize.cpp:29:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |  if(ans[1] > 0){
      |     ^~~
      |     abs