QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#389010 | #8549. The Game | ucup-team197# | WA | 4ms | 3804kb | C++17 | 1.8kb | 2024-04-13 23:20:12 | 2024-04-13 23:20:12 |
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 ] ;
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 ] ] ;
}
multiset < int > hh ;
int ones = 0 ;
for ( int i = 1 ; i <= 2 * n ; ++ i ) {
if ( freq[ i ] == 1 ) { ++ ones ; }
else if ( freq[ i ] > 1 ) { hh.insert ( freq[ i ] ) ; }
}
for ( int ctr = 0 ; ctr < 2 * n - 2 ; ++ ctr ) {
if ( ( ctr % 2 ) == 0 ) {
if ( ones > 0 ) { -- ones ; }
else {
auto it = hh.end ( ) ;
-- it ;
int val = *it ;
hh.erase ( it ) ;
-- val ;
if ( val == 1 ) { ++ ones ; }
else { hh.insert ( val ) ; }
}
}
else {
if ( hh.empty ( ) == false ) {
auto it = hh.begin ( ) ;
int val = *it ;
hh.erase ( it ) ;
-- val ;
if ( val == 1 ) { ++ ones ; }
else { hh.insert ( val ) ; }
}
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: 0ms
memory: 3668kb
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: 4ms
memory: 3804kb
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'