# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
921999 | Ianis | CONSUL (info1cup19_consul) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <algorithm>
#include <map>
#include <random>
#include "grader.h"
using namespace std;
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
using pii = pair<int, int>;
void solve(int n) {
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
map<int, bool> vis;
map<int, int> mp;
for (int i = 1; i <= 55 && i <= n; i++) {
int pos = abs(int(rng())) % n + 1;
if (!vis[pos]) {
vis[pos] = true;
mp[kth(pos)]++;
}
}
vector<pii> v;
for (auto [ val, fr ] : mp)
v.push_back({ -fr, val });
sort(all(v));
for (int i = 0; i < 5 && i < int(v.size()); i++) {
if (cnt(v[i].se) > n / 3) {
say_answer(v[i].se);
return;
}
}
say_answer(-1);
}