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 "grader.h"
#include <bits/stdc++.h>
using namespace std;
void solve(int n)
{
if (n <= -1)
{
map<int, int> mp;
for (int i = 1; i <= n; ++i)
{
++mp[kth(i)];
}
for (auto [key, value] : mp)
{
if (value > n / 3)
{
say_answer(key);
return;
}
}
say_answer(-1);
return;
}
srand(time(NULL));
map<int, bool> visited;
for (int i = 1; i <= 30; ++i)
{
int idx = 0;
while (true)
{
idx = rand() % n + 1;
if (visited.find(idx) == visited.end())
{
visited[idx] = true;
break;
}
}
int guess = kth(idx);
if (cnt(guess) > n / 3)
{
say_answer(guess);
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... |