Submission #637595

# Submission time Handle Problem Language Result Execution time Memory
637595 2022-09-02T12:56:41 Z tvladm2009 CONSUL (info1cup19_consul) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#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:11:20: error: could not convert 'mp.std::map<int, int>::find(x)' from 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} to 'bool'
   11 |         if (mp.find(x)) {
      |             ~~~~~~~^~~
      |                    |
      |                    std::map<int, int>::iterator {aka std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator}