Submission #498945

# Submission time Handle Problem Language Result Execution time Memory
498945 2021-12-26T19:42:29 Z cadmiumsky CONSUL (info1cup19_consul) C++14
Compilation error
0 ms 0 KB
#include <random>
#include <unordered_map>
#include <chrono>

using namespace std;

mt19937 rng(time(0));

void solve(int N) {
  if(N<=50) {
    unordered_map<int,int> freq;
    for(int i=1,x; i<=N; i++) {
      freq[x = kth(i)];
      freq[x]++;
    }
    for(auto x:freq) {
      if(x.second > N/3) {
        say_answer(x.first);
      }
    }
    say_answer(-1);
    return;
  }
  for(int i=0; i<30; i++) {
    int index=(rng()%N)+1;
    int val=kth(index);
    int freq=cnt(val);
    if(freq > N/3) {
      say_answer(val);
      return;
    }
  }
  say_answer(-1);
}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:13:16: error: 'kth' was not declared in this scope
   13 |       freq[x = kth(i)];
      |                ^~~
consul.cpp:18:9: error: 'say_answer' was not declared in this scope
   18 |         say_answer(x.first);
      |         ^~~~~~~~~~
consul.cpp:21:5: error: 'say_answer' was not declared in this scope
   21 |     say_answer(-1);
      |     ^~~~~~~~~~
consul.cpp:26:13: error: 'kth' was not declared in this scope
   26 |     int val=kth(index);
      |             ^~~
consul.cpp:27:14: error: 'cnt' was not declared in this scope; did you mean 'int'?
   27 |     int freq=cnt(val);
      |              ^~~
      |              int
consul.cpp:29:7: error: 'say_answer' was not declared in this scope
   29 |       say_answer(val);
      |       ^~~~~~~~~~
consul.cpp:33:3: error: 'say_answer' was not declared in this scope
   33 |   say_answer(-1);
      |   ^~~~~~~~~~