답안 #101916

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101916 2019-03-21T03:12:07 Z tim25871014 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "prize.h"
using namespace std;

int find_best(int n){

    int crd[200010]={};

    int loli=0;
    for(int i=0;i<500;i++){
        vector<int> ans=ask(i);
        loli=max(loli,ans[0]+ans[1]);
    }

    int l=0;
    while(ask(l)[1]!=0){
        int ub=n+1,lb=l;
        vector<int> ans;
        while(ub-lb>1){
            int mid=ub+lb>>1;
            if(!crd[mid]) ans=ask(mid);
            while((!crd[mid])?(;):(ans=ask(mid)),crd[mid] || ans[0]+ans[1]!=loli){
                crd[mid]=1;
                if(ans[0]+ans[1]==0) return mid;
                mid--;
            }
            if(ans[0]) ub=mid;
            else lb=mid;
        }
        ans=ask(lb);
        if(ans[0]+ans[1]==0) return lb;
        else l=lb+1;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:19:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid=ub+lb>>1;
                     ~~^~~
prize.cpp:21:32: error: expected primary-expression before ';' token
             while((!crd[mid])?(;):(ans=ask(mid)),crd[mid] || ans[0]+ans[1]!=loli){
                                ^
prize.cpp:21:32: error: expected ')' before ';' token
prize.cpp:21:32: error: expected ':' before ';' token
prize.cpp:21:32: error: expected primary-expression before ';' token
prize.cpp:21:32: error: expected ')' before ';' token
prize.cpp:21:13: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
             while((!crd[mid])?(;):(ans=ask(mid)),crd[mid] || ans[0]+ans[1]!=loli){
             ^~~~~
prize.cpp:21:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
             while((!crd[mid])?(;):(ans=ask(mid)),crd[mid] || ans[0]+ans[1]!=loli){
                                 ^
prize.cpp:21:33: error: expected primary-expression before ')' token
prize.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^