This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <random>
#include <unordered_map>
#include <chrono>
#include "grader.h"
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);
return;
}
}
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);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |