Submission #960657

# Submission time Handle Problem Language Result Execution time Memory
960657 2024-04-10T20:06:33 Z MarwenElarbi The Big Prize (IOI17_prize) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "prize.h"

using namespace std;
std::vector<int> ask(int i);

int find_best(int n){
    int bg=0;
    int cnt=0;
    /*for (int i = 0; i < min(480,n); ++i)
    {
        vector<int> cur=ask(i);
        if(cur[0]==0&&cur[1]==0) return i;
        if(cnt<=cur[0]+cur[1]){
            cnt=max(cnt,cur[0]+cur[1]);
            bg=i;
        }
    }*/
    while(true){
        //return 0;
        int l=bg;
        int r=n;
        //cout <<l<<endl;
        vector<int> fir=ask(l);
        if(fir[0]==0&&fir[1]==0) return l;
        while(r-l>1){
            int mid=(r+l)/2;
            vector<int> cur=ask(mid);
            if(cur[0]==0&&cur[1]==0) return mid;
            if(cur[0]==0) l=mid;
            else if(cur[0]+cur[1]!=cnt){
                r=mid;
                continue;   
            }
            else if(cur[1]+fir[0]!=cnt) r=mid;
            else {
                l=mid;
            }
        }
        bg=l+1;
        while(vis[bg]) bg++;
        fir=ask(bg);
        if(fir[0]==0&&fir[1]==0) return bg;
        while(fir[0]+fir[1]!=cnt){
            bg++;
            if(vis[bg]) continue;
            fir=ask(bg);
            if(fir[0]==0&&fir[1]==0) return bg;
        }
    }
    return n-1;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:41:15: error: 'vis' was not declared in this scope
   41 |         while(vis[bg]) bg++;
      |               ^~~
prize.cpp:46:16: error: 'vis' was not declared in this scope
   46 |             if(vis[bg]) continue;
      |                ^~~