제출 #249784

#제출 시각아이디문제언어결과실행 시간메모리
249784stoyan_malininThe Big Prize (IOI17_prize)C++14
컴파일 에러
0 ms0 KiB
#include "prize.h"
#include "grader.cpp"

#include <iostream>
#include <vector>

using namespace std;

int getLeft(int i)
{
    vector <int> res = ask(i);
    return res[0];
}

int getRight(int i)
{
    vector <int> res = ask(i);
    return res[1];
}

int getSum(int i)
{
    vector <int> res = ask(i);
    return res[0] + res[1];
}

pair <int, int> get(int i)
{
    vector <int> res = ask(i);
    return {res[0], res[1]};
}

bool check(pair <int, int> base, int newLast)
{
    if(base==get(newLast)) return true;
    return false;
}

int find_best(int n)
{
    int goalSum = 0;
    for(int i = 0;i<min(n, 500);i++)
    {
        int curr = getSum(i);
        goalSum = max(goalSum, curr);

        if(curr==0) return i;
    }

    int ind = 0;
    while(ind<n)
    {
        //cout << " --- " << ind << " --- " << '\n';

        pair <int, int> base;
        while(ind<n)
        {
            pair <int, int> curr = get(ind);
            base = curr;

            if(curr.first+curr.second==goalSum) break;
            if(curr.first+curr.second==0) return ind;

            ind++;
        }

        if(check(base, ind+min(10, n-ind-1))==false)
        {
            ind++;
            continue;
        }

        int last = ind;
        for(int i = (1LL<<18);i>=1;i/=2)
        {
            if(last+i>=n) continue;
            if(check(base, last+i)==true) last += i;
        }

        ind = last + 1;
    }
}
/*
9
3 3 2 3 2 3 1 3 3
*/

컴파일 시 표준 에러 (stderr) 메시지

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