Submission #976812

# Submission time Handle Problem Language Result Execution time Memory
976812 2024-05-07T06:54:49 Z LucaIlie The Big Prize (IOI17_prize) C++17
20 / 100
55 ms 2900 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 4e5;
int ans[MAX_N][2];

bool found = false;
int pos;

pair<int, int> askk( int i ) {
    if ( ans[i][0] == -1 ) {
        auto x = ask( i );
        ans[i][0] = x[0];
        ans[i][1] = x[1];
    }
    if ( ans[i][0] + ans[i][1] == 0 ) {
        found = true;
        pos = i;
    }
    return { ans[i][0], ans[i][1] };
}

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

    if ( l > r )
        return;

    int bs = max( 1, (r - l + 1) / 21  );
    //int bs = sqrt( r - l + 1 );
    int f = (l == 0 ? 0 : askk( l - 1 ).first );
    if ( found )
        return;
    
    for ( int lb = l; lb <= r; lb += bs ) {
        int rb = min( r, lb + bs - 1 );
        int g = askk( rb ).first;
        if ( found )
            return;
        if ( g - f > 0 ) {
            solve( lb + 1, rb - 1 );
            if ( found )
                return;
        }
        f = g;
    }
}

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

    solve( 0, n - 1 );

   // for ( int i = 0; i < n; i++ )
     //   askk( i );

    return pos;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2900 KB Output is correct
11 Correct 4 ms 2648 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 13 ms 2648 KB Output is correct
14 Correct 2 ms 600 KB Output is correct
15 Correct 16 ms 2648 KB Output is correct
16 Incorrect 55 ms 2648 KB Incorrect
17 Halted 0 ms 0 KB -