QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#389008 | #8549. The Game | ucup-team197# | WA | 3ms | 3756kb | C++17 | 1.7kb | 2024-04-13 23:15:18 | 2024-04-13 23:15:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair < int , int > pii ;
typedef vector < int > vi ;
#define fi first
#define se second
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
const int MAXN = 2e6 + 7 ;
int n ;
int a[ MAXN ] ;
int freq[ MAXN ] ;
vector < int > v ;
void solve ( ) {
cin >> n ;
for ( int i = 0 ; i <= 2 * n ; ++ i ) {
freq[ i ] = 0 ;
}
for ( int i = 1 ; i <= 2 * n ; ++ i ) {
cin >> a[ i ] ;
++ freq[ a[ i ] ] ;
}
v.clear ( ) ;
int ones = 0 ;
for ( int i = 1 ; i <= 2 * n ; ++ i ) {
if ( freq[ i ] == 1 ) { ++ ones ; }
else if ( freq[ i ] > 1 ) { v.push_back ( freq[ i ] ) ; }
}
sort ( v.begin ( ) , v.end ( ) ) ;
int sz = v.size ( ) ;
int tp = 0 ;
for ( int ctr = 0 ; ctr < 2 * n - 2 ; ++ ctr ) {
if ( ( ctr % 2 ) == 0 ) {
if ( ones > 0 ) { -- ones ; }
else {
if ( tp < sz && v[ tp ] > 1 ) {
-- v[ tp ] ;
if ( v[ tp ] == 1 ) { ++ tp ; ++ ones ; }
}
}
}
else {
if ( tp < sz && v[ tp ] > 1 ) {
-- v[ tp ] ;
if ( v[ tp ] == 1 ) { ++ tp ; ++ ones ; }
}
else { -- ones ; }
}
}
if ( ones == 0 ) { cout << "Qingyu\n" ; }
else { cout << "Kevin\n" ; }
}
int main ( ) {
ios_base :: sync_with_stdio ( false ) ;
cin.tie ( NULL ) ;
int t = 1 ; cin >> t ;
while ( t -- ) { solve ( ) ; }
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3608kb
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: 3ms
memory: 3756kb
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'