这不是模拟题 这是智商题.......
各种题意杀 写了一天
1. 桃只能自己吃,濒死时吃完记得回血,不要磕完桃还是0血状态
2. 用牌之前就要标记好不能再用了,避免出现杀死人结算的时候那张杀还在手里
3. 主公棋牌要弃装备
4. 无懈(打无懈)*
5. 杀死忠 不加牌 杀死反才加牌
6. 样例有误
7. 用南蛮入侵和万箭齐发的时候break掉了 结果跳出循环
8. 摸新牌要 把标记去掉
9. 最坑的一点! 如果5号位放南蛮,主公手里有杀,2号位手里有无懈可击,然后是2号位弃无懈而不是主公弃杀...
10.自己不跳身份时不能给自己打无懈可击 题目中有说,不跳身份的不能被打无懈可击,但忠臣任何时候都可以对主公打无懈可击
OI生涯写得最长代码 390行...
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
struct H
{
bool dead;
int zhong_fan;// 0 主 -1 反 1 忠
int tiao_zhong_fan; // 0 不跳 -1 跳反 1 跳忠 -2 类反猪
bool K;
bool zhu_ge;
int top;
char team[2000+10];
bool used[2000+10];
int HP;
}a[10+5];
int n,m;
int cnt_fan; //反贼个数
char s[5];
// 杀 K
// 桃 P
// 闪 D
// 决斗 F
// 南猪入侵 N
// 万箭齐发 W
// 无懈可击 J
// 猪哥连弩 Z
void EXIT()
{
if(cnt_fan==0) cout<<"MP"<<endl;
else cout<<"FP"<<endl;
for(int i=1;i<=n;i++)
{
if(a[i].dead==true) puts("DEAD");
else
{
int j=1;
for(;j<=a[i].top;j++)
if(!a[i].used[j])
{
printf("%c",a[i].team[j]);
break;
}
j++;
for(;j<=a[i].top;j++)
if(!a[i].used[j])
{
printf(" %c",a[i].team[j]);
// break;
}
// puts("");
if(i!=n)
printf("\n");
}
}
exit(0);
}
void get_card(int now)
{
// m--;cout<<m<<endl;
scanf("%s",s+1);
// cout<<"MO-"<<' '<<s[1]<<endl;
a[now].team[++a[now].top]=s[1];
a[now].used[a[now].top]=false;
}
bool out(int now,char kind)
{
for(int i=1;i<=a[now].top;i++)
if(a[now].team[i]==kind&&a[now].used[i]==false)
{
// cout<<now<<' '<<kind<<endl;
a[now].used[i]=true;
return true;
}
return false;
}
void D_HP(int now,int from)
{
a[now].HP--;
if(a[now].HP==0)
{
if(out(now,'P')==false)
{
a[now].dead=true;
if(a[now].zhong_fan==-1) cnt_fan--;
//EXIT();
if(now==1||cnt_fan==0)
{
EXIT();
}
if(a[now].zhong_fan==1&&from==1) a[from].top=0,a[from].zhu_ge=false;
else if(a[now].zhong_fan==-1) get_card(from),get_card(from),get_card(from);
}
else
{
a[now].HP=1;
}
}
}
bool out_wuxie(int now,int kind) // kind : 需要哪种猪打无懈
{
/* cout<<now<<' '<<kind<<endl;
for(int j=1;j<=a[1].top;j++)
if(!a[1].used[j])
printf("%c ",a[1].team[j]);
puts("");
*/
int i=now;
if(a[i].dead==false) //这只猪死了
if(a[i].zhong_fan==kind||(a[i].zhong_fan==0&&kind==1))
if(out(i,'J')==true)
{
if(i!=1) a[i].tiao_zhong_fan=kind; //主猪不会跳
// if(a[now].tiao_zhong_fan==-1) if(out_wuxie(i,-1)) return false;
// if(a[now].tiao_zhong_fan==1||now==1)
// if(a[i].tiao_zhong_fan==1||a[i].tiao_zhong_fan==-1)
if(out_wuxie(i,-kind)) return false;
return true;
}
for(;;)
{
i++;
if(i>n) i=1;
if(i==now) return false;
if(a[i].dead==true) continue ; //这只猪死了
// cout<<i<<' '<<kind<<' '<<(a[i].zhong_fan==0&&kind==1)<<endl;
if(a[i].zhong_fan==kind||(a[i].zhong_fan==0&&kind==1))
{
// cout<<i<<endl;
if(out(i,'J')==false) continue ; //没有"无懈可击"
// cout<<i<<endl;
if(i!=1) a[i].tiao_zhong_fan=kind; //主猪不会跳
// if(a[now].tiao_zhong_fan==-1) if(out_wuxie(i,-1)) return false;
// if(a[now].tiao_zhong_fan==1||now==1)
// if(a[i].tiao_zhong_fan==1||a[i].tiao_zhong_fan==-1)
if(out_wuxie(i,-kind)) return false;
return true;
}
}
}
void nanman_wanjian(int now,int kind)
{
for(int i=now;;)
{
i++;
if(i>n) i=1;
if(i==now) return ;// cout<<i<<endl;
if(a[i].dead==true) continue ; // 这只猪死了
// if(k==false)
{
// 这只猪 跳身份了 且被"无懈可击"救了
bool ok=true;
if(a[i].tiao_zhong_fan==-1) if(out_wuxie(now,-1)) ok=false;
if(a[i].tiao_zhong_fan==1||i==1) if(out_wuxie(now,1)) ok=false; //或者是 主猪
// i 受到伤害
if(ok){
bool k;
if(kind==1) k=out(i,'K'); else k=out(i,'D');
if(k==false){
D_HP(i,now);
if(i==1) if(a[now].tiao_zhong_fan==0) a[now].tiao_zhong_fan=-2;}
}
}
}
}
bool can_out(int now,int i)
{
// cout<<now<<' '<<a[now].team[i]<<endl;
if(a[now].used[i]==true) return false;
if(a[now].team[i]=='D') return false;
// 桃
if(a[now].team[i]=='P')
{
if(a[now].HP!=4)
{
a[now].HP++;
out(now,'P');
// a[now].used[i]=true;
return true;
}
return false;
}
// 南猪入侵
if(a[now].team[i]=='N')
{
out(now,'N');
// a[now].used[i]=true;
nanman_wanjian(now,1);
return true;
}
// 万箭齐发
if(a[now].team[i]=='W')
{
out(now,'W');
//a[now].used[i]=true;
nanman_wanjian(now,0);
return true;
}
// 杀
if(a[now].team[i]=='K')
{
if(a[now].K==true&&a[now].zhu_ge==false) return false; //已经出过杀且没有装备猪哥连弩
int t=now+1;// 他的下家
if(t>n) t=1;
while(a[t].dead==true)
{
t=t+1;
if(t>n) t=1;
}
// cout<<t<<' '<<a[t].tiao_zhong_fan<<endl;
if(a[now].zhong_fan==0&&(a[t].tiao_zhong_fan==0||a[t].tiao_zhong_fan==1)) return false; //主公不杀不跳或跳忠的
if(a[now].zhong_fan==1&&(a[t].tiao_zhong_fan!=-1)) return false; //忠臣只杀跳反的
if(a[now].zhong_fan==-1&&((t==1||a[t].tiao_zhong_fan==1)==false))return 0;
if(a[t].tiao_zhong_fan==1||t==1) a[now].tiao_zhong_fan=-1;
if(a[t].tiao_zhong_fan==-1&&now!=1) a[now].tiao_zhong_fan=1;
// cout<<t<<endl;
// cout<<t<<' ';
out(now,'K');
// a[now].used[i]=true; //弃置此牌
a[now].K=true; //出过杀
if(out(t,'D')==false) D_HP(t,now);
return true;
}
// 决斗
if(a[now].team[i]=='F')
{
int t; //cout<<now<<' '<<a[now].zhong_fan<<endl;
if(a[now].zhong_fan==-1) t=1;
else // 否则是忠或主的话
{
//
t=now+1;if(t>n) t=1;
while(t!=now)
{// cout<<"******"<<endl;
if(a[t].dead==false)
if(a[t].tiao_zhong_fan==-1||(now==1&&a[t].tiao_zhong_fan==-2))
{
break;
}
t++;
if(t>n) t=1;
}
if(t==now) return false;
}
/* cout<<t<<endl;
for(int j=1;j<=a[2].top;j++)
if(!a[2].used[j])
printf("%c ",a[2].team[j]);
*/
// cout<<t<<' ';
out(now,'F');
// a[now].used[i]=true;// 此牌弃置
if(t==1||a[t].tiao_zhong_fan==1) a[now].tiao_zhong_fan=-1;
if(a[t].tiao_zhong_fan==-1&&now!=1) a[now].tiao_zhong_fan=1;
if(a[t].tiao_zhong_fan==1||t==1) if(out_wuxie(now,1)) return true;
if(a[t].tiao_zhong_fan==-1) if(out_wuxie(now,-1)) return true;
// if(now==1&&a[t].zhong_fan==1) cout<<"888888888888888888888888"<<endl;
if(((now==1&&a[t].zhong_fan==1)==false)&&out(t,'K')==true) //忠不会打主猪的决斗
{//cout<<!(now==1&&a[t].zhong_fan==1)<<endl;
while(true) //轮流出杀 不能出掉血
{
if(out(now,'K')==false)
{
// if(a[now].tiao_zhong_fan==1||now==1) if(out_wuxie(t,1)) return true;
// if(a[now].tiao_zhong_fan==-1) if(out_wuxie(t,-1)) return true;
D_HP(now,t);
break;
}
if(out(t,'K')==false)
{
// if(a[t].tiao_zhong_fan==1||now==1) if(out_wuxie(now,1)) return true;
// if(a[t].tiao_zhong_fan==-1) if(out_wuxie(now,-1)) return true;
D_HP(t,now);
break;
}
}
}
else
{
D_HP(t,now);
}
return true;
}
// 无懈可击
if(a[now].team[i]=='J') return false;
// 猪哥连弩
if(a[now].team[i]=='Z')
{
a[now].zhu_ge=true;
out(now,'Z');
// a[now].used[i]=true;
return true;
}
}
bool out_card(int now)
{
for(int i=1;i<=a[now].top;i++)
if(can_out(now,i)==true)
{
// cout<<'*'<<now<<' '<<a[now].team[i]<<endl;
return true;
}
return false;
}
// now的出牌阶段 每出一张牌 从头开始扫描能出的牌
void solve(int now)
{
get_card(now);
get_card(now);
a[now].K==false;
while(true)
{
// cout<<"now"<<endl;
if(a[now].dead==true) return ;
if(out_card(now)==true) ;
else break;
}
}
int main()
{
// freopen("kopk19.in","r",stdin);
// freopen("a.out","w",stdout);
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++)
{
a[i].dead = false;
a[i].HP=4;
scanf("%s",s+1);// cout<<s[1]<<endl;
if(s[1]=='M') a[i].zhong_fan = 0;
else if(s[1]=='Z') a[i].zhong_fan=1;
else a[i].zhong_fan=-1,cnt_fan++;
for(int j=1;j<=4;j++) get_card(i);
}
// return 0;
int now=1;
while(true)
{
/* cout<<"**********"<<now<<endl;
{
cout<<a[now].dead<<endl;
cout<<a[now].tiao_zhong_fan<<endl;
cout<<a[now].HP<<endl;
for(int j=1;j<=a[now].top;j++)
if(!a[now].used[j])
printf("%c ",a[now].team[j]);
puts("");
}
cout<<a[1].HP<<endl;*/
if(a[now].dead==false)
{
solve(now);
}
now++;
if(now>n) now=1;
}
return 0;
}