Submission #945125

# Submission time Handle Problem Language Result Execution time Memory
945125 2024-03-13T12:32:18 Z Wansur The Big Prize (IOI17_prize) C++14
20 / 100
29 ms 6100 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'

typedef long long ll;
using namespace std;

struct asd{
    int a, b, w, ca, cb;
};

vector<int> ask(int i);
const string out[2]={"NO\n","YES\n"};
const ll dx[]={0,1,0,-1,-1,1,1,-1};
const ll dy[]={1,0,-1,0,-1,1,-1,1};
const int mod=998244353;
const int md=1e9+7;
const int mx=2e5+12;
const bool T=0;

vector<int> ans[mx];
int ma;

vector<int> Ask(int i){
    if(ans[i].size()){
        return ans[i];
    }
    return ans[i]=ask(i);
}

int find(int l,int r,int x,int left,int right){
    if(!x || l>r)return -1;
    int mid=l+r>>1, cnt=0;
    for(int x=0;mid-x>=l || mid+x<=r;x++){
        if(mid+x<=r){
            auto a=Ask(mid+x);
            if(a[0]+a[1]==ma){
                int val=find(mid+x+1, r, a[1]-right, a[0], right);
                if(val!=-1)return val;
                val=find(l, mid - x - (x==0), a[0] - cnt - left, left, a[1] + cnt);
                return val;
            }
            if(a[0]+a[1]==0){
                return mid+x;
            }
            cnt++;
        }
        if(mid-x>=l){
            auto a=Ask(mid-x);
            if(a[0]+a[1]==ma){
                int val=find(l, mid-x-1, a[0]-left, left, a[1]);
                if(val!=-1)return val;
                val=find(mid+x+1, r, a[1] - cnt - right, a[0] + cnt, right);
                return val;
            }
            if(a[0]+a[1]==0){
                return mid-x;
            }
            cnt++;
        }
    }
    return -1;
}

int find_best(int n){
    int pos=0,cnt=0;
    for(int i=0;i<478;i++){
        auto a=Ask(i);
        if(a[0]+a[1]==0){
            return i;
        }
        if(a[0]+a[1]>ma){
            ma=a[0]+a[1];
            cnt=0;
        }
        if(a[0]+a[1]==ma){
            cnt++;
        }
        pos=i;
        if(ma>sqrt(sqrt(n))*2+50){
            break;
        }
    }
    return find(pos+1, n-1, ma - cnt, cnt, 0);
}

Compilation message

prize.cpp: In function 'int find(int, int, int, int, int)':
prize.cpp:34:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |     int mid=l+r>>1, cnt=0;
      |             ~^~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5648 KB Output is correct
2 Correct 4 ms 5392 KB Output is correct
3 Correct 4 ms 5400 KB Output is correct
4 Correct 3 ms 5388 KB Output is correct
5 Correct 3 ms 5388 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 3 ms 5400 KB Output is correct
8 Correct 4 ms 5636 KB Output is correct
9 Correct 3 ms 5388 KB Output is correct
10 Correct 4 ms 5396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5396 KB Output is correct
2 Correct 4 ms 5388 KB Output is correct
3 Correct 4 ms 5392 KB Output is correct
4 Correct 3 ms 5396 KB Output is correct
5 Correct 3 ms 5144 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 3 ms 5396 KB Output is correct
8 Correct 3 ms 5652 KB Output is correct
9 Correct 4 ms 5396 KB Output is correct
10 Correct 3 ms 5396 KB Output is correct
11 Correct 5 ms 5660 KB Output is correct
12 Correct 5 ms 5652 KB Output is correct
13 Correct 3 ms 5392 KB Output is correct
14 Correct 6 ms 6100 KB Output is correct
15 Correct 19 ms 5928 KB Output is correct
16 Correct 5 ms 5400 KB Output is correct
17 Incorrect 29 ms 6004 KB Integer -1 violates the range [0, 199999]
18 Halted 0 ms 0 KB -