Submission #125925

#TimeUsernameProblemLanguageResultExecution timeMemory
125925MasterdanThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include "prize.h" #include <bits/stdc++.h> #define MIN -1 #define MAX 1000000000 #define all(a) a.begin (), a.end () #define mp make_pair #define pb push_back using namespace std; typedef vector <int> vi; typedef long long int ll; typedef pair <int, int> ii; int binary (int a, int b){ vector <int> v; v=ask((a+b)/2); if(v[0]==1){ return binary(a, (a+b)/2); }else{ if(v[1]==1)return binary((a+b)/2+1, b); } if(v[0]==0 and v[1]==0)return (a+b)/2; } int find_best(int n) { return binary(0, n-1); } 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; 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; } int main() { cin >> n; g.resize(n); for(int i = 0; i < n; i++) { cin >> g[i]; if(g[i] < 1) { cerr << "Invalid rank " << g[i] << " at index " << i << endl; exit(0); } } int max_rank = *max_element(g.begin(), g.end()); rank_count.resize(max_rank + 1, vector<int>(n + 1, 0)); for(int r = 0; r <= max_rank; r++) { for(int i = 1; i <= n; i++) { rank_count[r][i] = rank_count[r][i - 1]; if(g[i - 1] == r) rank_count[r][i]++; } } for(int i = 0; i <= n; i++) for(int r = 1; r <= max_rank; r++) rank_count[r][i] += rank_count[r - 1][i]; int res = find_best(n); cout << res << endl << "Query count: " << query_count << endl; return 0; }

Compilation message (stderr)

prize.cpp: In function 'int binary(int, int)':
prize.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/tmp/ccKpCLnG.o: In function `ask(int)':
grader.cpp:(.text+0x0): multiple definition of `ask(int)'
/tmp/ccbsh7u1.o:prize.cpp:(.text+0x0): first defined here
/tmp/ccKpCLnG.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccbsh7u1.o:prize.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status