And wrong of bzoj1972: loj2885: p2482 [SDOI2010] kill pigs States

Subject to the effect

Only put the link up.

The title did not say one thing: it is not enough to ensure the brand, but again and again draw the last card in the card is not enough.

answer

It found that the number of players is relatively small, so the time may not care enough to use.

Consider three things: 1 basic operations, such as Mopai, the cards, the player dies, the brand effect; 2 game flow; three card objects....

  1. Mopai, cards:
    found for "a player's card" from left to right sweep operation is first available, then delete (the cards), or to the far right and two on the (Mopai), two operations well maintained as a linked list. It suggested that "to judge from the player \ (x \) hand, there is no value \ (k \) , if they can, put the leftmost \ (k \) by deleting" and "at the player \ (x \) The most right-hand put two cards. "these two operations written two functions. It recommends that in mind \ (a_i \) represents the player \ (i \) if loaded weapons.
    Player dies:
    use lists maintained for each player before and after surviving players. When a player dies, the first sentence hands have no P, and if so, the amount of blood to 1 and resurrection (because all of the cards can cause damage, can only cause harm to 1, so it will not drop below 0); if no, the player dies, if the player is MP or last FP, the game is over, otherwise FP words source of damage to touch three cards, is the ZP and the source of damage is then MP MP's hand list to clear and let \ (a_1 = 0 \) .
    Brand effect:
    \ (the X-\) to \ (y \) a K: \ (the X-\) disclosure of the identity, determine \ (y \) if there is D, no matter if it happened, if not then \ (y \ ) blood volume reduction, judge \ (y \) whether death.
    \ (X \) a P: blood +1.
    \ (X \) a Z: Order \ (= a_x. 1 \) .
    \ (x \) the J: \ (x \) identity exposed, from \ (x \) in this order to determine whether there is a successful player J, if so, then J is canceled; if not, \ (x \) out J take effect. Recommendations implemented recursive function.
    \ (x \) the N or W: from \ (x \) player on the right of this order to determine whether each player will be injured, for each player, from \ (x \) in this order to determine whether there are players out J, if the players have not happened, if it is determined that no player can not be a K or D, if that player nothing happened, otherwise the player DOT, judgment of death. Both AOE almost the same, write a recommendation. Note that, AOE hit show their identity when his teammates could themselves out of their AOE J.
    \ (x \) to \ (y \) the F: \ (x \) disclosure of the identity, sentenced J, judge whether \ (x \) as an MP and \ (y \) for the ZP. Maintains two pointers, respectively, taking into account the current \ (x, y \) in the first few cards. Moves the pointer to the next turn K, if one is not K, the DOT side determines death.

  2. Note of the current players for the \ (the X-\) , with each player maintain lists before and after surviving players. If the death list of players before and after the death of the update. For (x \) \ round, first touch two cards, then sweep from left to right, if no license can be out the end of the round, otherwise the cards, and then again to determine whether there may be a card (because F, AOE finished out after the players may have a J, exposure status, it could lead to \ (x \) and some cards may become out). Note that \ (x \) bout probably because \ (x \) death interrupted ( \ (x \) an F to make their death), note that \ (x \) that turn out over whether K.

  3. K: adjacent to the right in their own, and have shown that identity, and enemy players.
    F: MP counterclockwise to indicate the identity of the first class of anti-FP or swine; ZP counterclockwise first to show the identity of the FP; FP will only MP.
    J: remember \ (f (x, y, z) \ space z \ in \ {0,1 \} \) represents the card is \ (X \) of \ (Y \) a \ (Z \) behavior ( \ (z = 1 \) represents gallant, \ (z = 0 \) a table showing hostility), would have been offset. If \ (z = 1 \) and \ (K \) that \ (X \) is the enemy and \ (K \) has a J, the \ (K \) out of J, then \ (f (k, x, 0 ) \) determines that J is in effect; if \ (z = 0 \) and \ (K \) that \ (Y \) is friendly and \ (K \) has a J, the \ (K \) out of J, then \ (f (k, y, 1) \) determines that J is in effect. Note To change the cards at the moment the "surface identity," the dealer, or will affect whether the other players J.

After completion of these want, the next step is to write. Like analog content and a slightly different topic will describe a large ...... WA

Code
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define rep(i,x,y) for(register int i=(x);i<=(y);++i)
#define dwn(i,x,y) for(register int i=(x);i>=(y);--i)
#define viewcd(u,k) for(int k=nxt[u];k;k=nxt[k])
#define LL long long
#define maxn 17
#define maxm 2007
using namespace std;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')f=-1,ch=getchar();
    while(isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
    return x*f;
}
void write(int x)
{
    if(x==0){putchar('0'),putchar('\n');return;}
    int f=0;char ch[20];
    if(x<0)putchar('-'),x=-x;
    while(x)ch[++f]=x%10+'0',x/=10;
    while(f)putchar(ch[f--]);
    putchar('\n');
    return;
}
int numpg,numcd,cf,stp;
int h[maxn],w[maxn],p[maxn],n[maxn],fake[maxn],real[maxn];
int nxt[maxm<<1],pre[maxm<<1],cntcd,chg;
char c[maxm<<1],C[maxm],s[10];
void addcd(int x,int k)
{
    rep(i,1,k)
    {
        c[++cntcd]=C[numcd--];if(!numcd)numcd=1;
        nxt[pre[x]]=cntcd,pre[cntcd]=pre[x],pre[x]=cntcd,nxt[cntcd]=x;
    }
}//x gets k cards.
void del(int x,int k)
{
    int nk=nxt[k],pk=pre[k];
    pre[nk]=pk,nxt[pk]=nk;
}//x lose card k
void clear(){nxt[1]=pre[1]=1;w[1]=0;return;}//x lose its cards.
void kil(int x,int y)
{
    if(real[y]==1&&x==1){clear();}
    else if(real[y]==3){cf--;if(!cf)stp=1;if(!stp)addcd(x,3);}
    else if(y==1)stp=1;
    if(stp)return;
    int ny=n[y],py=p[y];p[ny]=py,n[py]=ny;
}//x kill y.
int getcd(int x,char tp)
{
    for(int k=nxt[x];k!=x;k=nxt[k])
        if(tp==c[k]){del(x,k);return 1;}
    return 0;
}//get card tp of x.
int reborn(int x){if(!getcd(x,'P'))return 0;h[x]=1;return 1;}//x is going to die.
int enemy(int x,int y){if(((fake[y]&1)&&fake[y]!=real[x])||(x==1&&fake[y]==2))return 1;return 0;}//x wants to kill y.
int nedJ(int x,int y,int f)
{
    for(int k=n[x];k!=x;k=n[k])
    {
        if(!f&&fake[y]==real[k])
        {
            if(getcd(k,'J'))
            {
                fake[k]=real[k];
                if(!nedJ(k,y,1))return 1;
            }
        }
        if(f&&enemy(k,x))
        {
            if(getcd(k,'J'))
            {
                fake[k]=real[k];
                if(!nedJ(k,x,0))return 1;
            }
        }
    }
    return 0;
}///x use ... on y
//0:enemy;1:friend
int prot(int x,int y)
{
    if(fake[y]==real[x]){if(getcd(x,'J')){fake[x]=real[x];if(!nedJ(x,y,1))return 1;}}
    for(int k=n[x];k!=x;k=n[k])if(fake[y]==real[k])
    {
        if(getcd(k,'J'))
        {
            fake[k]=real[k];
            if(!nedJ(k,y,1))return 1;
        }
    }
    return 0;
}//x use ... on y
void K(int x,int y)
{
    fake[x]=real[x];
    if(!getcd(y,'D')){h[y]--;if(h[y]==0&&!reborn(y))kil(x,y);}
}//
void F(int x,int y)
{
    int kx=nxt[x],ky=nxt[y];
    fake[x]=real[x];
    if(prot(x,y))return;
    if(real[y]!=1||x!=1)
    {
        while(ky!=y)
        {
            for(;ky!=y;ky=nxt[ky])if(c[ky]=='K')break;
            if(c[ky]!='K')break;
            del(y,ky),ky=nxt[ky],swap(x,y),swap(kx,ky);
        }
    }
    if((real[y]==1&&x==1)||c[ky]!='K'){h[y]--;if(h[y]==0&&!reborn(y))kil(x,y);}
}//
void AOE(int x,char tp)//tp=='N':'K', tp=='W':'D'
{
    char ned=(tp=='N')?'K':'D';
    for(int y=n[x];y!=x;y=n[y])if(!prot(x,y))
    {
        if(!getcd(y,ned))
        {
            h[y]--;
            if(!h[y]&&!reborn(y))kil(x,y);
            if(stp)return;
            if(y==1&&!fake[x])fake[x]=2;
        }
    }
}
int main()
{
    numpg=read(),numcd=read();cntcd=numpg;
    rep(i,1,numpg)
    {
        scanf("%s",s);pre[i]=nxt[i]=i;
        real[i]=(s[0]=='M'||s[0]=='Z')?1:3;fake[i]=(i==1)?1:0;
        rep(j,1,4)
        {
            scanf("%s",s);
            c[++cntcd]=s[0];
            nxt[pre[i]]=cntcd,pre[cntcd]=pre[i],pre[i]=cntcd,nxt[cntcd]=i;
        }p[i]=(i-1)==0?numpg:i-1,n[i]=i==numpg?1:i+1,h[i]=4;
        if(real[i]==3) cf++;
    }
    rep(i,1,numcd){scanf("%s",s);C[numcd-i+1]=s[0];}
    if(cf==0)stp=1;
    for(int x=1;!stp;x=n[x]) 
    {
        addcd(x,2);int mk=0,k;
        usecd:
        chg=0;
        for(k=nxt[x];k!=x;k=nxt[k])
        {
            if(c[k]=='K'&&(!mk||w[x])&&enemy(x,n[x]))
            {
                mk=1;del(x,k),K(x,n[x]);chg=1;break;
            }
            else if(c[k]=='F')
            {
                int y;
                if(real[x]==3){del(x,k),F(x,1);}
                else 
                {
                    for(y=n[x];y!=x;y=n[y])if(enemy(x,y)){break;}
                    if(!enemy(x,y))continue;
                    del(x,k),F(x,y);
                }
                chg=1;break;
            }
            else if(c[k]=='N'||c[k]=='W'){del(x,k),AOE(x,c[k]);chg=1;break;}
            else if(c[k]=='Z'){del(x,k),w[x]=1;chg=1;break;}
            else if(c[k]=='P'&&h[x]<4){del(x,k),h[x]++;}
        }
        if(chg&&!stp&&h[x]){goto usecd;}
        if(stp)break;
    }
    puts(h[1]>0?"MP":"FP");
    rep(i,1,numpg)
    {
        if(h[i]<=0){printf("DEAD");}
        else {for(int k=nxt[i];k!=i;k=nxt[k]){printf("%c ",c[k]);}}
        puts("");
    }
    return 0;
}
Some thoughts

Finally we can do anything to stem the play!

Guess you like

Origin www.cnblogs.com/xzyf/p/11276120.html