Submission #51014

# Submission time Handle Problem Language Result Execution time Memory
51014 2018-06-15T15:22:48 Z FLDutchman The Big Prize (IOI17_prize) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.cpp"
//#include "prize.h"
using namespace std;

#define mp make_pair
#define pb push_back
const int INF = 1000000000;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double num;
typedef pair<num, num> nn;
typedef vector<nn> vnn;
typedef vector<num> vn;
typedef vector<vn> vvn;

vii answers;
int maxVal = 0;
int N;

ii query(int i){
    if(answers[i] != mp(-1, -1)) return answers[i];
    vi a = ask(i);
    return answers[i] = mp(a[0], a[1]);
}


void genQueries(){
    // do 711 queries in the shape of a bs
    queue<ii> bounds;
    bounds.push(mp(-1, N));
    int queriesLeft = 711;
    while(queriesLeft --){
        ii q = bounds.front(); bounds.pop();
        int mb = (q.first+q.second)/2;
        query(mb);
        maxVal = max(maxVal, answers[mb].first + answers[mb].second);
        bounds.push(mp(q.first, mb));
        bounds.push(mp(mb, q.second));
    }
}

int find_best(int n){
    N = n;
    int betterFound = 0;
    int lb = -1;
    while(betterFound < maxVal){
        int rb =  n;
        while(lb + 1 != rb){
            int mb = (lb + rb)/2;
            ii ans = query(mb);
            if(ans.second < maxVal - betterFound){
                rb = mb;
            } else {
                lb = mb;
            }
        }
        betterFound++;
        lb++;
    }

    for(int i = 0; i < answers.size(); i++){
        if(answers[i] == mp(0, 0)) return i;
    }

}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:66:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < answers.size(); i++){
                    ~~^~~~~~~~~~~~~~~~
prize.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/tmp/cchOhfG2.o: In function `ask(int)':
grader.cpp:(.text+0x0): multiple definition of `ask(int)'
/tmp/cc84Urji.o:prize.cpp:(.text+0x0): first defined here
/tmp/cchOhfG2.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc84Urji.o:prize.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status