답안 #637594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
637594 2022-09-02T12:56:23 Z tvladm2009 CONSUL (info1cup19_consul) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <grader.h>

using namespace std;

void solve(int n) {
    srand(time(NULL));
    map<int, int> mp;
    while (true) {
        int x = rand() % n + 1;
        if (mp.find(x)) {
            continue;
        }
        mp[x] = true;
        if (cnt(kth(x)) > n / 3) {
            say_answer(x);
            return;
        }
    }
    say_answer(-1);
}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:8:5: error: 'map' was not declared in this scope
    8 |     map<int, int> mp;
      |     ^~~
consul.cpp:3:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
    2 | #include <grader.h>
  +++ |+#include <map>
    3 | 
consul.cpp:8:9: error: expected primary-expression before 'int'
    8 |     map<int, int> mp;
      |         ^~~
consul.cpp:11:13: error: 'mp' was not declared in this scope
   11 |         if (mp.find(x)) {
      |             ^~
consul.cpp:14:9: error: 'mp' was not declared in this scope
   14 |         mp[x] = true;
      |         ^~