Submission #467507

# Submission time Handle Problem Language Result Execution time Memory
467507 2021-08-23T11:56:40 Z LucaIlie CONSUL (info1cup19_consul) C++17
Compilation error
0 ms 0 KB
//#include <stdio.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( q );
                return;
            }
        }
    }

    say_answer( -1 );
}

/*int main() {
    int n;

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

    return 0;
}*/

Compilation message

consul.cpp:3:10: error: #include expects "FILENAME" or <FILENAME>
    3 | #include grader.h
      |          ^~~~~~
consul.cpp: In function 'void solve(int)':
consul.cpp:40:13: error: 'rand' was not declared in this scope
   40 |         i = rand() % n;
      |             ^~~~
consul.cpp:43:17: error: 'kth' was not declared in this scope
   43 |             x = kth( i + 1 );
      |                 ^~~
consul.cpp:49:18: error: 'cnt' was not declared in this scope; did you mean 'int'?
   49 |             if ( cnt( x ) > n / 3 ) {
      |                  ^~~
      |                  int
consul.cpp:50:17: error: 'say_answer' was not declared in this scope
   50 |                 say_answer( q );
      |                 ^~~~~~~~~~
consul.cpp:56:5: error: 'say_answer' was not declared in this scope
   56 |     say_answer( -1 );
      |     ^~~~~~~~~~