Submission #127018

#TimeUsernameProblemLanguageResultExecution timeMemory
127018VlatkoThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include "prize.h"
#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;


int find_best(int n) {
    vector<pii> cur, nxt;
    cur.emplace_back(0, n-1);
    while (!cur.empty()) {
        nxt.clear();
        sort(cur.begin(), cur.end(), [&] (pii& a, pii& b) {
            int sza = a.second-a.first;
            int szb = b.second-b.first;
            if (sza != szb) return sza < szb;
            return a.first < b.first;
        });
        for (auto& p : cur) {
            int l = p.first, r = p.second;
            if (l == r) {
                vector<int> res = ask(l);
                if (res[0] == 0 && res[1] == 0) {
                    return l;
                }
            } else {
                int m = (l + r) / 2;
                vector<int> res = ask(m);
                if (res[0] == 0 && res[1] == 0) {
                    return m;
                } else if (res[0] == 1 && res[1] == 0) {
                    nxt.emplace_back(l, m);
                } else if (res[0] == 0 && res[1] == 1) {
                    nxt.emplace_back(m+1, r);
                } else {
                    nxt.emplace_back(l, m);
                    nxt.emplace_back(m+1, r);
                }
            }
        }
        swap(cur, nxt);
    }
    return 0;
}

Compilation message (stderr)

/tmp/ccqkHtOg.o: In function `ask(int)':
grader.cpp:(.text+0x0): multiple definition of `ask(int)'
/tmp/ccUDTz7n.o:prize.cpp:(.text+0x520): first defined here
/tmp/ccqkHtOg.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccUDTz7n.o:prize.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status