Submission #687597

# Submission time Handle Problem Language Result Execution time Memory
687597 2023-01-26T15:54:42 Z Rares CONSUL (info1cup19_consul) C++14
Compilation error
0 ms 0 KB
#include <grader.h>


void Solve (int N){
    int op=0;
    srand (time (0));
    vector <int> a;
    while (1){
        int x=kth (rand ());
        op++;
        if (op>=59){
            say_answer (-1);
            break;
        }
        bool ok=0;
        for (int i=0;i<a.size ();++i){
            if (a[i]==x){
                ok=1;
                break;
            }
        }
        if (ok==0){
            a.push_back (x);
            int f=cnt (x);
            op++;
            if (f>N/3){
                say_answer (x);
                break;
            }
            if (op>=59){
                say_answer (-1);
            }
        }
    }
}


Compilation message

consul.cpp: In function 'void Solve(int)':
consul.cpp:7:12: error: 'time' was not declared in this scope
    7 |     srand (time (0));
      |            ^~~~
consul.cpp:7:5: error: 'srand' was not declared in this scope
    7 |     srand (time (0));
      |     ^~~~~
consul.cpp:8:5: error: 'vector' was not declared in this scope
    8 |     vector <int> a;
      |     ^~~~~~
consul.cpp:8:13: error: expected primary-expression before 'int'
    8 |     vector <int> a;
      |             ^~~
consul.cpp:10:20: error: 'rand' was not declared in this scope
   10 |         int x=kth (rand ());
      |                    ^~~~
consul.cpp:17:24: error: 'a' was not declared in this scope
   17 |         for (int i=0;i<a.size ();++i){
      |                        ^
consul.cpp:24:13: error: 'a' was not declared in this scope
   24 |             a.push_back (x);
      |             ^