[2019杭电多校第七场][hdu6655]Just Repeat

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6655

题意是说两个人都有一些带有颜色的牌,两人轮流出牌,但是不能出对面出过的颜色的牌,最后谁不能出牌谁输。

贪心的想,如果这种牌我有对方也有,那我肯定先出以此来减少对方可出的牌,如果有几种这样的牌,那肯定是先出两方手牌总和最多的那种颜色。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<string>
 5 #include<algorithm>
 6 #include<vector>
 7 #include<map>
 8 using namespace std;
 9 typedef long long ll;
10 typedef unsigned long long ull;
11 const int maxn = 2e5 + 110;
12 struct node {
13     ll id, num;
14     node() {}
15     node(ll _id, ll _num) { id = _id, num = _num; }
16 }q[maxn];
17 int a[maxn], b[maxn], num[maxn], numa[maxn], numb[maxn];
18 ull k1, k2;
19 int mod;
20 ull rng() {
21     unsigned long long k3 = k1, k4 = k2;
22     k1 = k4;
23     k3 ^= k3 << 23;
24     k2 = k3 ^ k4 ^ (k3 >> 17) ^ (k4 >> 26);
25     return k2 + k4;
26 }
27 bool cmp(node a, node b) {
28     return a.num > b.num;
29 }
30 int main() {
31     int t;
32     scanf("%d", &t);
33     while (t--) {
34         int n, m, p, len = 0, cnt = 0;
35         scanf("%d%d%d", &n, &m, &p);
36         if (p == 1) {
37             for (int i = 1; i <= n; i++)
38                 scanf("%d", &a[i]), num[++len] = a[i];
39             for (int i = 1; i <= m; i++)
40                 scanf("%d", &b[i]), num[++len] = b[i];
41         }
42         else {
43             scanf("%llu%llu%d", &k1, &k2, &mod);
44             for (int i = 1; i <= n; i++)
45                 a[i] = (int)(rng() % mod), num[++len] = a[i];
46             scanf("%llu%llu%d", &k1, &k2, &mod);
47             for (int i = 1; i <= m; i++)
48                 b[i] = (int)(rng() % mod), num[++len] = b[i];
49         }
50         sort(num + 1, num + 1 + len);
51         len = unique(num + 1, num + 1 + len) - num - 1;
52         for (int i = 0; i <= len; i++)
53             numa[i] = numb[i] = 0;
54         for (int i = 1; i <= n; i++) {
55             int x = lower_bound(num + 1, num + 1 + len, a[i]) - num;
56             numa[x]++;
57         }
58         for (int i = 1; i <= m; i++) {
59             int x = lower_bound(num + 1, num + 1 + len, b[i]) - num;
60             numb[x]++;
61         }
62         for (int i = 1; i <= len; i++) {
63             if (numa[i] && numb[i])
64                 q[++cnt] = node(i, numa[i] + numb[i]);
65         }
66         sort(q + 1, q + 1 + cnt, cmp);
67         int w = 1, suma = n, sumb = m;
68         for (int i = 1; i <= cnt; i++) {
69             if (w & 1)
70                 suma--, sumb -= numb[q[i].id];
71             else
72                 sumb--, suma -= numa[q[i].id];
73             w++;
74         }
75         if (w & 1) {
76             if (suma > sumb)
77                 printf("Cuber QQ\n");
78             else
79                 printf("Quber CC\n");
80 
81         }
82         else {
83             if (sumb > suma)
84                 printf("Quber CC\n");
85             else
86                 printf("Cuber QQ\n");
87 
88         }
89     }
90 }

 

posted @ 2019-08-20 20:59  祈梦生  阅读(174)  评论(0编辑  收藏  举报