#ifdef LC
#include "pch.h"
#else
#include <bits/stdc++.h>
#include "grader.h"
#endif
using namespace std;
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple
int kth(int i);
int cnt(int x);
void say_answer(int a);
mt19937 rnd;
void solve(int n) {
int q = 48;
set<int> ind;
set<int> was;
while (q > 0 && (int)ind.size() < n) {
int i = 1 + (int)(rnd() % n);
while (ind.count(i)) {
i = (int)(rnd() % n);
}
int v = kth(i);
--q;
if (was.count(v)) {
continue;
}
int c = cnt(v);
--q;
if (3 * c > n) {
say_answer(v);
return;
}
}
say_answer(-1);
}
#ifdef LC
const int N = 50;
map<int, int> cn;
int v[N];
int kth(int i) {
return v[i];
}
int cnt(int x) {
return cn[x];
}
void say_answer(int x) {
cout << "answer " << x << endl;
}
signed main() {
assert(freopen("input.txt", "r", stdin));
ios::sync_with_stdio(0); cin.tie(0);
for (int i = 0; i < N; ++i) {
v[i] = i / (N / 3);
++cn[v[i]];
}
// for (auto e : cn) {
// cout << e.x << " " << e.y << endl;
// }
solve(N);
return 0;
}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
364 KB |
Output is correct |
2 |
Correct |
9 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
364 KB |
Output is correct |
2 |
Correct |
18 ms |
364 KB |
Output is correct |
3 |
Correct |
9 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
380 KB |
Output is correct |
5 |
Correct |
20 ms |
364 KB |
Output is correct |
6 |
Correct |
27 ms |
364 KB |
Output is correct |
7 |
Correct |
17 ms |
364 KB |
Output is correct |
8 |
Correct |
22 ms |
364 KB |
Output is correct |
9 |
Correct |
27 ms |
364 KB |
Output is correct |
10 |
Correct |
21 ms |
364 KB |
Output is correct |
11 |
Correct |
17 ms |
364 KB |
Output is correct |
12 |
Correct |
18 ms |
364 KB |
Output is correct |
13 |
Correct |
29 ms |
364 KB |
Output is correct |
14 |
Correct |
24 ms |
364 KB |
Output is correct |