#include<bits/stdc++.h>
#define endl '\n'
#define MAXN 15
using namespace std;
int n,m;
int player_type[MAXN],hp[MAXN],fan_num;
bool weapon[MAXN],zhong[MAXN],fan[MAXN],leifan[MAXN],dead[MAXN];
queue<int> cards;
vector<int> hand[MAXN];
int have_card(char c){
if(c=='P'){
return 1;
}
else if(c=='K'){
return 2;
}
else if(c=='D'){
return 3;
}
else if(c=='Z'){
return 4;
}
return 0;
}
char out_card(int a){
if(a==0){
return 'p';
}
if(a==1){
return 'P';
}
else if(a==2){
return 'K';
}
else if(a==3){
return 'D';
}
else if(a==4){
return 'Z';
}
return 'p';
}
void join_card(int i){
hand[i].push_back(have_card(cards.front()));
if(cards.size()!=1){
cards.pop();
}
}
void out_hand(){
for(int i=1;i<=n;i++){
if(dead[i]){
cout<<"DEAD"<<endl;
}
else{
// cout<<hp[i]<<" "<<weapon[i]<<"# ";
for(int now_card:hand[i]){
int tmp=out_card(now_card);
if(tmp=='p'){
continue;
}
cout<<out_card(now_card)<<' ';
}
cout<<endl;
}
}
// cout<<'-'<<endl;
}
void is_end(){
if(dead[1]){
cout<<"FP"<<endl;
out_hand();
exit(0);
}
else if(fan_num<=0){
cout<<"MP"<<endl;
out_hand();
exit(0);
}
}
int ex(int i){
is_end();
int j=i+1;
for(j=i+1;j<=n;j++){
if(!dead[j]){
break;
}
}
if(j>n){
return 1;
}
else{
return j;
}
}
void death(int i,int from){
for(unsigned int j=0;j<hand[i].size();j++){
int now_card=hand[i][j];
if(now_card==1 and hp[i]<=0){
hp[i]++;
}
}
if(hp[i]>0){
return;
}
dead[i]=true;
if(player_type[i]==2){
fan_num--;
is_end();
join_card(from);
join_card(from);
join_card(from);
}
else if(player_type[i]==1 and from==1){
is_end();
hand[from].clear();
weapon[from]=false;
}
is_end();
}
void res_kill(int i,int from){
for(unsigned int j=0;j<hand[i].size();j++){
int now_card=hand[i][j];
if(now_card==3){
hand[i][j]=0;
return;
}
}
hp[i]--;
if(hp[i]<=0){
death(i,from);
}
}
bool do_kill(int i){
int tmp=player_type[i];
if(tmp==1 and i!=1){
if(fan[ex(i)]){
res_kill(ex(i),i);
zhong[i]=true;
return true;
}
}
else if(tmp==2){
if(zhong[ex(i)] or ex(i)==1){
res_kill(ex(i),i);
fan[i]=true;
return true;
}
}
else{
if(fan[ex(i)] or leifan[ex(i)]){
res_kill(ex(i),i);
return true;
}
}
return false;
}
void act(int i){
is_end();
join_card(i);
join_card(i);
bool flag=true;
for(unsigned int j=0;j<hand[i].size();j++){
int now_card=hand[i][j];
if(now_card==1 and hp[i]<4){
hand[i][j]=0;
hp[i]++;
}
else if(now_card==2 and (flag or weapon[i])){
if(do_kill(i)){
hand[i][j]=0;
flag=false;
}
}
else if(now_card==4){
weapon[i]=true;
hand[i][j]=0;
j=0;
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
zhong[1]=true;
for(int i=1;i<=n;i++){
string a;
cin>>a;
hp[i]=4;
if(a[0]=='Z'){
player_type[i]=1;
}
if(a[0]=='F'){
fan_num++;
player_type[i]=2;
}
for(int j=1;j<=4;j++){
char c;
cin>>c;
hand[i].push_back(have_card(c));
}
}
for(int i=1;i<=m;i++){
char c;
cin>>c;
cards.push(have_card(c));
}
while(true){
for(int i=1;i<=n;i++){
// out_hand();
if(!dead[i]) act(i);
is_end();
}
is_end();
}
return 0;
}
只要找出原因就好了QWQ,能改的话更好,悬赏两个关注,谢谢大佬的调试