QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#548002#8549. The Gameucup-team059#WA 5ms3832kbC++201.2kb2024-09-05 14:36:082024-09-05 14:36:09

Judging History

你现在查看的是最新测评结果

  • [2024-09-05 14:36:09]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3832kb
  • [2024-09-05 14:36:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve() {
    int n;
    cin >> n;
    map<int,int> cnt;
    for (int i = 1;i <= 2 * n;i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    int one = 0;
    priority_queue<int> q;
    for (auto [a,c] : cnt){
        if (c == 1) one++;
        else{
            q.push(c);
        }
    }
    int t = 0;
    while (!q.empty() || one){
        if (q.size() == 1 && q.top() == 2){
            cout << "Qingyu\n";
            return;
        }
        if (!t){
            if (q.empty()) one--;
            else{
                int x = q.top();
                x--;
                q.pop();
                if (x == 1) one++;
                else q.push(x);
            }
        }else{
            if (one) one--;
            else{
                int x = q.top();
                x--;
                q.pop();
                if (x == 1) one++;
                else q.push(x);
            }
        }
        t ^= 1;
    }
    cout << "Kevin\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

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: 5ms
memory: 3832kb

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
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu
Qingyu...

result:

wrong answer 3rd words differ - expected: 'Kevin', found: 'Qingyu'