Submission #975492

# Submission time Handle Problem Language Result Execution time Memory
975492 2024-05-05T10:10:44 Z pirhosig The Big Prize (IOI17_prize) C++17
Compilation error
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;



int solve(int low, int upp, ii a, ii b) {
	while (a.first + a.second != b.first + b.second) {
		if (a.first + a.second < b.first + b.second) {
			low++;
			auto qres = ask(low);
			a.first = qres[0];
			a.second = qres[1];
			if (a.second + a.first == 0) return low;
		}
		else {
			upp--;
			auto qres = ask(upp);
			b.first = qres[0];
			b.second = qres[1];
			if (b.first + b.second == 0) return upp;
		}
	}
	if (a.first == b.first) return 0;
	int mid = (low + upp) / 2;
	return solve(low, mid, a, b) + solve(mid, upp, a, b);
}


	
int find_best(int n) {
	auto qres = ask(0);
	ii a = {qres[0], qres[1]};
	auto qres = ask(n - 1);
	ii b = {qres[0], qres[1]};
	return solve(0, n - 1, a, b);
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:35:7: error: conflicting declaration 'auto qres'
   35 |  auto qres = ask(n - 1);
      |       ^~~~
prize.cpp:33:7: note: previous declaration as 'std::vector<int> qres'
   33 |  auto qres = ask(0);
      |       ^~~~