이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "grader.h"
#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
void kout(){ cerr << endl; }
template<class T1, class ...T2> void kout(T1 a, T2 ...e) { cerr << a << ' ', kout(e...); }
int cnt(int x) { return 1; }
void say_answer(int v) { cerr << "Ans is " << v << '\n'; }
int kth(int i) { return 1; }
#else
#define DE(...) 0
#define deubg(...) 0
#endif
const int MAX_N = 300010;
random_device rd;
mt19937 gen(rd());
void solve(int n)
{
uniform_int_distribution<int> dis(1, n);
const int lim = min(n, 60);
if (n <= 50) {
map<int,int> CT;
for (int i = 1;i <= n;++i)
CT[ kth(i) ]++;
for (auto [a, b] : CT)
if (b * 3 > n) {
say_answer(a);
return;
}
say_answer(-1);
return;
}
unordered_set<int> test, did;
int cur_cnt = 0;
while (cur_cnt + 2 <= lim && did.size() < n) {
int id = dis(gen);
if (did.count(id))
continue;
did.insert(id);
int x = kth(id);
if (test.count(x))
continue;
test.insert(x);
if (cnt(x) > n / 3) {
say_answer(x);
return ;
}
}
say_answer(-1);
return;
}
컴파일 시 표준 에러 (stderr) 메시지
consul.cpp: In function 'void solve(int)':
consul.cpp:46:42: warning: comparison of integer expressions of different signedness: 'std::unordered_set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | while (cur_cnt + 2 <= lim && did.size() < n) {
| ~~~~~~~~~~~^~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |