hdu6655 2019 Hangzhou Radio & Television Multicultural School Seventh Event

This question is the most watery one in the whole field... The list was skewed

Writing started in the last half hour of the game, and then I didn't think clearly at first... WA, and then think of the problem, 16:52 do not know how to change... In fact, a little careful push is very simple, the final time of the game is a little tense.

Considering that Cuber QQ is playing now, he has two choices. If he has a card with many cards, he can not let the other side play it. The second option was not taken into account when I was in WA before. He had many cards with the color i, but with this card opposite, we will produce a card with the color I in this round, so that we can keep so many cards with the color I.

So let's take out the cards that both sides have and sort them by numa[i]+numb[i]. Everyone's current optimal strategy is sure to have a card with the highest value.

As you take it, figure out how many cards each side has left, and then compare them according to the situation of successive hands.

#include<bits/stdc++.h>
#define maxl 200010
using namespace std;
typedef unsigned long long ull;

int n,m,p,cnt,tot,mod,cntc;
ull k1,k2;
bool ans;
int a[maxl],b[maxl],f[maxl];
int numa[maxl],numb[maxl];
int num[maxl];
struct node
{
    int col,num;
}c[maxl];
bool ainb[maxl],bina[maxl];

inline 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;
}

inline bool cmp(const node &x,const node &y)
{
    return x.num<y.num;
}

inline void prework()
{
    cnt=0;
    scanf("%d%d%d",&n,&m,&p);
    if(p==1)
    {
        for(register int i=1;i<=n;++i)
            scanf("%d",&a[i]),num[++cnt]=a[i];
        for(register int i=1;i<=m;++i)
            scanf("%d",&b[i]),num[++cnt]=b[i];
    }
    else
    {
        scanf("%llu%llu%d",&k1,&k2,&mod);
        for(register int i=1;i<=n;++i)
            a[i]=(int)(rng()%mod),num[++cnt]=a[i];
        scanf("%llu%llu%d",&k1,&k2,&mod);
        for(register int i=1;i<=m;++i)
            b[i]=(int)(rng()%mod),num[++cnt]=b[i];
    }
    sort(num+1,num+1+cnt);
    tot=unique(num+1,num+1+cnt)-num-1;
    for(register int i=1;i<=tot;++i)
        numa[i]=numb[i]=0;
    for(register int i=1;i<=n;++i)
    {
        a[i]=lower_bound(num+1,num+1+tot,a[i])-num;
        numa[a[i]]++;
    }
    for(register int i=1;i<=m;++i)
    {
        b[i]=lower_bound(num+1,num+1+tot,b[i])-num;
        numb[b[i]]++;
    }
    cntc=0;
    for(register int i=1;i<=tot;i++)
    {
    	if(numa[i]>0 && numb[i]>0)
			c[++cntc]=node{i,numa[i]+numb[i]}; 
    }
    sort(c+1,c+1+cntc,cmp);
}

inline void mainwork()
{
    int id=1,resa=n,resb=m;
    for(int i=cntc;i>=1;i--)
    {
    	if(id&1)
    		resa--,resb-=numb[c[i].col];
    	else
    		resb--,resa-=numa[c[i].col];
    	id++;
	}
    if(id&1)
    {
        if(resa>resb)
            ans=true;
        else
            ans=false;
    }
    else
    {
        if(resb>resa)
            ans=false;
        else
            ans=true;
    }
}

inline void print()
{
    if(ans)
        puts("Cuber QQ");
    else
        puts("Quber CC");
}

int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        prework();
        mainwork();
        print();
    }
    return 0;
}

 

Posted by Ludichrist on Mon, 07 Oct 2019 16:28:48 -0700