Submission #976924

# Submission time Handle Problem Language Result Execution time Memory
976924 2024-05-07T09:12:24 Z Error404 The Big Prize (IOI17_prize) C++17
20 / 100
779 ms 1048576 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define f first
#define s second
const int MAX_N = 2e5;
int ans[MAX_N][2];

bool found = false;
int pos;

int last ;
pi q(int l){
    if(ans[l][0]!=-1) return {ans[l][0], ans[l][1]};
    else{
       auto hold  = ask(l);
        ans[l][0] =hold[0];
        ans[l][1] =hold[1];
        return {ans[l][0], ans[l][1]};
     // return {0,1};
    }
}


void solve( int l, int r ) {
    if(found) return;

    if(l>r) return;
    int m = (l+r)/2;
    pi res = q(m);

    if(res.f ==0 && res.s==0){
        pos = m;
        found = true;
        return;
    }

    if(res.f!=0){
        solve(l,min(m,last-1));
    }
    if(res.s!=0){
        solve(max(0,m+1),r);
    }



}

int find_best( int n ) {
    for( int i = 0; i < n; i++ )
        ans[i][0] = ans[i][1] = -1;
    last = n-1;
    solve( 0, n - 1 );

    return pos;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 1 ms 2128 KB Output is correct
3 Correct 1 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 1 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
11 Runtime error 779 ms 1048576 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -