Problem 3038 --Just Repeat

3038: Just Repeat

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
When Cuber QQ was chatting happily in a QQ group one day, he accidentally noticed that there was a counterfeit of him, who stole his avatar and mimicked his tone, and more excessively, had a nickname "Quber CC", which was sarcastic to him. So Cuber QQ decided to play a little game with this Quber CC, and their bet was, whoever lost the game would have to do something really humiliating in front of everyone in the QQ group. 

The game is like this. It's a traditional card game. Cuber QQ will play first. Cuber QQ, and his opponent (Quber CC of course), will each possess a hand of cards. There is no number (or rank if you prefer) on the card, but only color (or suit if you prefer). The players play cards alternatively, each player can only play one card in each turn. An additional rule is that, a player must not play a card with the same color as any card which has been played by his/her opponent, but coincidence with a card played by himself/herself is acceptable. 

The player who can't play any card loses. This might due to the fact that he/she has cards but he cannot play any due to the game rules, or he doesn't have any cards any more. As a game played between civilized people, the game will be played in a completely transparent manner, where Cuber QQ and Quber CC know exactly what's left in their opponent's hand. 

It's now a game attracting thousands of eyes, and you decided to invent a predictor whose job is to predict "who will win if both players play smart" to excite the audience. 
The first line of the input is a positive integer tt, denoting the number of test cases. 

Then follows tt test cases, each test case starts with space-separated integers nnmmpp (1≤n,m≤1051≤n,m≤105p∈{1,2}p∈{1,2}). Generally speaking, this should be followed by two lines of integers a1,a2,…,ana1,a2,…,an and b1,b2,…,bmb1,b2,…,bm, denoting the colors of Cuber QQ's hand and Quber CC's hand, respectively. Unfortunately, as it turns out, the input will be the bottleneck in that case. So we introduce pp to deal with this problem. 

For p=1p=1, there follows two lines, where the first line is a1,a2,…,ana1,a2,…,an and the second line is b1,b2,…,bmb1,b2,…,bm, all space separated and 0≤ai,bi<1090≤ai,bi<109

For p=2p=2, there follows two lines, which are k1,k2,modk1,k2,mod (0≤k1,k2<2640≤k1,k2<2641≤mod≤1091≤mod≤109) to generate {ai}{ai} and {bi}{bi}, respectively. 

Here are some instructions on how to generate {ai}{ai}{bi}{bi} with k1,k2,modk1,k2,mod, which you've probably seen before, somehow: 

unsigned long long k1, k2;
unsigned long long rng() {
    unsigned long long k3 = k1, k4 = k2;
    k1 = k4;
    k3 ^= k3 << 23;
    k2 = k3 ^ k4 ^ (k3 >> 17) ^ (k4 >> 26);
    return k2 + k4;
}
// generate
read(k1, k2, mod);
for (int i = 0; i < n; ++i)
    a[i] = rng() % mod;
read(k1, k2, mod);
for (int i = 0; i < m; ++i)
    b[i] = rng() % mod;


Also, the sum of n+mn+m for p=1p=1 does not exceed 5⋅1055⋅105; the sum of n+mn+m from all test cases does not exceed 107107.
For each test case, predict the winner: "Cuber QQ" or "Quber CC".
2
6 7 1
1 1 4 5 1 4
1 9 1 9 8 1 0
10 20 2
1 2 10
1 2 10
Cuber QQ
Quber CC

推荐代码 查看3038 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战 淡意的温柔 591127 2020-06-06 08:27:31

赛题来源/所属竞赛 2019 Multi-University Training Contest 7 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛