QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#464996 | #8549. The Game | ucup-team191# | WA | 2ms | 5680kb | C++23 | 1.1kb | 2024-07-06 16:42:41 | 2024-07-06 16:42:41 |
Judging History
answer
#include <cstdio>
using namespace std;
const int N = 2e6 + 500;
int n, A[N], cnt[N], cnt2[N];
int solve() {
scanf("%d", &n);
for(int i = 0;i <= 2 * n;i++) cnt[i] = 0, cnt2[i] = 0;
for(int i = 0;i < 2 * n;i++) {
scanf("%d", A + i);
cnt[A[i]]++;
}
bool ok = 1;
for(int i = 0;i < n;i++)
if(A[i] != A[2 * n - i - 1]) ok = 0;
if(ok) {
printf("Qingyu\n");
return 0;
}
for(int i = 0;i <= 2 * n;i++) {
if(cnt[i]) cnt2[cnt[i]]++;
}
int L = 0, R = 2 * n;
for(int i = 0;i < n;i++) {
while(!cnt2[L]) L++;
while(!cnt2[R]) R--;
cnt2[R]--;
if(i == n - 1) break;
if(R - 1) cnt2[R - 1]++;
while(!cnt2[L]) L++;
while(!cnt2[R]) R--;
if(L == R && cnt2[L] == 1) {
printf("Qingyu\n");
return 0;
}
while(!cnt2[L]) L++;
while(!cnt2[R]) R--;
cnt2[L]--;
if(L - 1) cnt2[--L]++;
while(!cnt2[L]) L++;
while(!cnt2[R]) R--;
if(L == R && cnt2[L] == 1) {
printf("Qingyu\n");
return 0;
}
}
printf("Kevin\n");
return 0;
}
int main() {
int T; scanf("%d", &T);
for(;T--;) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5680kb
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: 2ms
memory: 5664kb
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 Kevin Kevin Qingyu Qingyu Kevin Kevin Kevin Kevin Qingyu Kevin Kevin Kevin Kevin Kevin Qingyu Kevin Kevin Kevin Kevin Kevin Kevin Qingyu Kevin Kevin Kevin Qingyu Kevin Kevin Kevin Kevin Kevin Qingyu Kevin Kevin Kevin Kevin Kevin Qingyu Kevin Kevin Kevin Qingyu Qingyu...
result:
wrong answer 23rd words differ - expected: 'Qingyu', found: 'Kevin'