제출 #498945

#제출 시각아이디문제언어결과실행 시간메모리
498945cadmiumskyCONSUL (info1cup19_consul)C++14
컴파일 에러
0 ms0 KiB
#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);
}

컴파일 시 표준 에러 (stderr) 메시지

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);
      |   ^~~~~~~~~~