QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#474092 | #8549. The Game | real_sigma_team# | WA | 7ms | 3748kb | C++20 | 1.2kb | 2024-07-12 16:03:12 | 2024-07-12 16:03:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define x first
#define y second
void solve();
int main() {
#ifndef LOCAL
cin.tie(nullptr)->sync_with_stdio(false);
#endif
cout << fixed << setprecision(30);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
void solve() {
int n;
cin >> n;
map<int, int> cnt;
for (int i = 0; i < 2 * n; ++i) {
int x;
cin >> x;
cnt[x]++;
}
set<pair<int, int>> odd, even;
for (auto [x, y] : cnt) if (y & 1) odd.emplace(y, x); else even.emplace(y, x);
for (int i = 0; i < n - 1; ++i) {
{
int del;
if (even.size()) {
del = even.begin()->second;
even.erase({cnt[del], del});
} else {
del = odd.begin()->second;
odd.erase({cnt[del], del});
}
cnt[del]--;
if (cnt[del] > 0) {
if (cnt[del] & 1) odd.emplace(cnt[del], del);
else even.emplace(cnt[del], del);
}
}
{
int del;
if (odd.empty()) {
del = even.begin()->second;
even.erase({cnt[del], del});
} else {
del = odd.begin()->second;
odd.erase({cnt[del], del});
}
cnt[del]--;
if (cnt[del] > 0) {
if (cnt[del] & 1) odd.emplace(cnt[del], del);
else even.emplace(cnt[del], del);
}
}
}
if (even.size()) cout << "Qingyu\n";
else cout << "Kevin\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
input:
3 3 1 1 4 5 1 4 2 1 2 3 4 4 1 2 2 3 2 1 1 4
output:
Qingyu Kevin Qingyu
result:
ok 3 tokens
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 3440kb
input:
10000 3 5 5 3 5 4 5 3 1 4 3 1 1 3 3 1 6 3 3 4 4 3 3 4 1 3 1 1 3 5 6 6 3 1 3 3 4 5 1 5 6 5 3 6 2 4 4 6 1 3 4 6 4 4 2 4 3 6 4 1 6 4 6 3 2 4 6 4 2 3 3 2 4 1 5 5 4 3 1 3 6 5 1 1 3 3 2 1 5 3 1 3 6 6 6 2 2 5 3 1 5 2 5 3 3 3 1 3 3 5 4 5 3 1 3 4 2 4 5 3 3 5 6 2 2 2 3 4 3 3 1 2 6 3 3 3 3 3 6 3 3 4 1 3 6 6 4 ...
output:
Qingyu Qingyu Kevin Qingyu Kevin Qingyu Kevin Qingyu Qingyu Kevin Kevin Qingyu Kevin Qingyu Kevin Kevin Kevin Qingyu Kevin Qingyu Kevin Kevin Qingyu Qingyu Kevin Qingyu Qingyu Qingyu Kevin Kevin Qingyu Kevin Kevin Kevin Kevin Kevin Qingyu Qingyu Kevin Qingyu Kevin Kevin Qingyu Qingyu Kevin Kevin Qin...
result:
wrong answer 6th words differ - expected: 'Kevin', found: 'Qingyu'