Submission #112060

#TimeUsernameProblemLanguageResultExecution timeMemory
112060Eug1enaGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

void MinMax(lint s, lint t, lint &mn, lint &mx){
    cout << s << " " << t << endl;
    lint a, b;
    cin >> a >> b;
    mn = a, mx = b;
}

lint findGap(int T, int N){
    if(T == 1){
        vector<lint> left{-INF}, right{INF + 100};
        while(left.back() + 2 <= right.back()){
            lint l, r;
            MinMax(left.back() + 1, right.back() - 1, l, r);
            if(l == -1){
                break;
            }
            left.push_back(l);
            right.push_back(r);
        }
        vector<lint> a;
        for(int i = 1; i < left.size(); i++){
            a.push_back(left[i]);
        }
        for(int i = int(right.size()) - 1; i >= 1; i--){
            a.push_back(right[i]);
        }
        lint ans = 0;
        for(int i = 1; i < a.size(); i++){
            ans = max(ans, a[i] - a[i - 1]);
        }
        return ans;
    }else{
        return -1;
    }
}

int main(){
    cout << findGap(1, 6) << endl; // 2, 4, 5, 7, 12, 16
}

Compilation message (stderr)

gap.cpp: In function 'lint findGap(int, int)':
gap.cpp:26:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 1; i < left.size(); i++){
                        ~~^~~~~~~~~~~~~
gap.cpp:33:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 1; i < a.size(); i++){
                        ~~^~~~~~~~~~
/tmp/ccsiLpC1.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccQ0o4d0.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status