Submission #905337

#TimeUsernameProblemLanguageResultExecution timeMemory
905337nightfalThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include "prize.h"
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

static const int max_q = 10000;
static int n;
static int query_count = 0;
static vector<int> g;
static vector<vector<int> > rank_count;

int find_best(int n);
std::vector<int> ask(int i);

int subtask1(int n){
    int start=0, end=n-1;
    while (start<end) {
        int mid = (start+end)/2;
        vector<int> ans = ask(mid);
        if (!ans[0] && !ans[1]) return mid;
        else if (!ans[0]) start=mid+1;
        else end = mid-1;
    }
    return start;
}

int find_best(int n) {
    return subtask1(n);
	for(int i = 0; i < n; i++) {
		std::vector<int> res = ask(i);
		if(res[0] + res[1] == 0)
			return i;
	}
	return 0;
}


vector<int> ask(int i) {
	query_count++;
	if(query_count > max_q) {
		cerr << "Query limit exceeded" << endl;
		exit(0);
	}

	if(i < 0 || i >= n) {
		cerr << "Bad index: " << i << endl;
		exit(0);
	}

	vector<int> res(2);
	res[0] = rank_count[g[i] - 1][i + 1];
	res[1] = rank_count[g[i] - 1][n] - res[0];
	return res;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cce9P2cQ.o: in function `ask(int)':
grader.cpp:(.text+0x80): multiple definition of `ask(int)'; /tmp/cckv5LsO.o:prize.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status