1 条题解
-
0许致远___ (XZYxuzhiyuan) LV 7 @ 2022-3-25 21:01:38
#include<bits/stdc++.h> using namespace std; struct node{ int cs,hp,next,last; char id,card[2010]; bool zgln; }a[20]; char kn[11],kpd[2010],sss[10]; int n,m,fz; bool ed; void mp(int x){ if(!m) m++; a[x].card[++a[x].cs]=kpd[m]; m--; } void js(int x1,int x2){ for(int i=1;i<=a[x2].cs;i++) if(a[x2].card[i]=='P'){ a[x2].card[i]='U'; a[x2].hp++; return ; } a[a[x2].next].last=a[x2].last; a[a[x2].last].next=a[x2].next; if(x2==1){ed=true;return ;} if(a[x2].id=='F')fz--; if(!fz){ed=true;return ;} if(a[x2].id=='F')mp(x1),mp(x1),mp(x1); if(a[x2].id=='Z'&&a[x1].id=='M')a[x1].cs=0,a[x1].zgln=false; } void Kil(int x1,int x2){ for(int i=1;i<=a[x2].cs;i++) if(a[x2].card[i]=='D'){ a[x2].card[i]='U'; return ; } a[x2].hp--; if(!a[x2].hp)js(x1,x2); } bool wxkj(int x1,int x2,int x3){ int i=x1,pd=x3?x2:x1; while(1){ if(x3){ if(kn[x2]==a[i].id||(kn[x2]=='M'&&a[i].id=='Z')||(kn[x2]=='Z'&&a[i].id=='M')) for(int j=1;j<=a[i].cs;j++) if(a[i].card[j]=='J'){ a[i].card[j]='U'; kn[i]=a[i].id; return !wxkj(i,x1,0); } } else{ if(((a[i].id=='M'||a[i].id=='Z')&&kn[x1]=='F')||(a[i].id=='F'&&(kn[x1]=='M'||kn[x1]=='Z'))) for(int j=1;j<=a[i].cs;j++) if(a[i].card[j]=='J'){ a[i].card[j]='U'; kn[i]=a[i].id; return !wxkj(i,x1,0); } } i=a[i].next; if(i==x1)break; } return false; } void nmrq(int x1){ for(int x2=a[x1].next;x2!=x1;x2=a[x2].next) if(!wxkj(x1,x2,1)){ int i; for(i=1;i<=a[x2].cs;i++) if(a[x2].card[i]=='K'){ a[x2].card[i]='U'; break; } if(i>a[x2].cs){ a[x2].hp--; if(x2==1&&kn[x1]=='U')kn[x1]='L'; if(!a[x2].hp)js(x1,x2); if(ed) return ; } } } void wjqf(int x1){ for(int x2=a[x1].next;x2!=x1;x2=a[x2].next) if(!wxkj(x1,x2,1)){ int i; for(i=1;i<=a[x2].cs;i++) if(a[x2].card[i]=='D'){ a[x2].card[i]='U'; break; } if(i>a[x2].cs){ a[x2].hp--; if(x2==1&&kn[x1]=='U')kn[x1]='L'; if(!a[x2].hp)js(x1,x2); if(ed) return ; } } } void jd(int x1,int x2){ int i,j,k; if(wxkj(x1,x2,1))return ; if(x1==1 && a[x2].id=='Z'){ a[x2].hp--; if(!a[x2].hp)js(x1,x2); return ; } j=k=1; while(1){ while(a[x2].card[j]!='K'&&j<=a[x2].cs)j++; if(j>a[x2].cs){ a[x2].hp--; if(!a[x2].hp)js(x1,x2); return ; } else a[x2].card[j]='U'; while(a[x1].card[k]!='K'&&k<=a[x1].cs)k++; if(k>a[x1].cs){ a[x1].hp--; if(!a[x1].hp)js(x2,x1); return ; } else a[x1].card[k]='U'; } } void hh(){ char nc; ed=true; if(fz) ed=false; if(ed) return ; for(int i=1;i;i=a[i].next){ mp(i),mp(i); bool kill=true; for(int j=1;j<=a[i].cs;j++) if(a[i].card[j]!='U'){ if(!a[i].hp) break; nc=a[i].card[j]; if(nc=='P'){ if(a[i].hp!=4)a[i].hp++,a[i].card[j]='U'; continue; } if(nc=='K'){ if(!kill&&!a[i].zgln)continue; if(a[i].id=='M'&&kn[a[i].next]!='L'&&kn[a[i].next]!='F')continue; if(a[i].id=='Z'&&kn[a[i].next]!='F')continue; if(a[i].id=='F'&&kn[a[i].next]!='Z'&&kn[a[i].next]!='M')continue; a[i].card[j]='U'; Kil(i,a[i].next); kn[i]=a[i].id,kill=false; if(ed) return ; continue; } if(nc=='F'){ if(a[i].id=='F'){ a[i].card[j]='U',jd(i,1); kn[i]=a[i].id; if(ed) return ; j=0; continue; } for(int k=a[i].next;k!=i;k=a[k].next) if((a[i].id=='M'&&(kn[k]=='L'||kn[k]=='F'))||(a[i].id=='Z'&&kn[k]=='F')){ a[i].card[j]='U',jd(i,k); kn[i]=a[i].id; if(ed)return ; j=0; break; } continue; } if(nc=='N'){ a[i].card[j]='U'; nmrq(i); if(ed) return ; j=0; continue; } if(nc=='W'){ a[i].card[j]='U'; wjqf(i); if(ed) return ; j=0; continue; } if(nc=='Z'){ a[i].zgln=true; a[i].card[j]='U'; j=0; continue; } } } } int main(){ scanf("%d %d",&n,&m); for(int i=1;i<=n;i++)a[i].next=i+1,a[i].last=i-1; a[n].next=1,a[1].last=n; for(int i=1;i<=n;i++){ for(int j=1;j<2010;j++)a[i].card[j]='U'; scanf("%s",sss); a[i].id=sss[0]; for(int j=1;j<=4;j++){ scanf("%s",sss); a[i].card[j]=sss[0]; } a[i].cs=a[i].hp=4; if(a[i].id=='F')fz++; a[i].zgln=false; } for(int i=2;i<=n;i++) kn[i]='U'; kn[1]='M'; for(int i=1;i<=m;i++){ scanf("%s",sss); kpd[m-i+1]=sss[0]; } hh(); if(a[1].hp<=0) printf("FP\n"); else printf("MP\n"); for(int i=1;i<=n;i++){ if(a[i].hp<=0)printf("DEAD\n"); else{ for(int j=1;j<=a[i].cs;j++){ if(a[i].card[j]!='U')printf("%c ",a[i].card[j]); } printf("\n"); } } return 0; }
无数据qwq......
- 1
信息
- ID
- 1827
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- (无)
- 递交数
- 13
- 已通过
- 0
- 上传者