Submission #467514

# Submission time Handle Problem Language Result Execution time Memory
467514 2021-08-23T12:01:52 Z LucaIlie CONSUL (info1cup19_consul) C++17
100 / 100
37 ms 276 KB
//#include <stdio.h>
#include <stdlib.h>
#include <map>
#include "grader.h"

#define MAX_Q 60

using namespace std;

map <int, int> checkedPoz, checkedVal;

/*int kth( int i ) {
    int ans;

    printf( "kth %d\n", i );
    scanf( "%d", &ans );

    return ans;
}

int cnt( int x ) {
    int ans;

    printf( "cnt %d\n", x );
    scanf( "%d", &ans );

    return ans;
}

void say_answer( int ans ) {
    printf( "%d\n", ans );
}*/

void solve( int n ) {
    int q, i, x;

    checkedPoz.clear();
    checkedVal.clear();
    q = 0;
    while ( q < MAX_Q && q < n ) {
        i = rand() % n;
        if ( !checkedPoz[i] ) {
            checkedPoz[i] = 1;
            x = kth( i + 1 );
            q++;
        }

        if ( q < MAX_Q && q < n && !checkedVal[x] ) {
            checkedVal[x] = 1;
            if ( cnt( x ) > n / 3 ) {
                say_answer( x );
                return;
            }
            q++;
        }
    }

    say_answer( -1 );
}

/*int main() {
    int n;

    scanf( "%d", &n );
    solve( n );

    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 14 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 200 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 200 KB Output is correct
2 Correct 21 ms 200 KB Output is correct
3 Correct 9 ms 200 KB Output is correct
4 Correct 7 ms 200 KB Output is correct
5 Correct 22 ms 200 KB Output is correct
6 Correct 24 ms 200 KB Output is correct
7 Correct 32 ms 276 KB Output is correct
8 Correct 27 ms 200 KB Output is correct
9 Correct 29 ms 216 KB Output is correct
10 Correct 26 ms 200 KB Output is correct
11 Correct 30 ms 276 KB Output is correct
12 Correct 19 ms 200 KB Output is correct
13 Correct 37 ms 200 KB Output is correct
14 Correct 20 ms 200 KB Output is correct