记录编号 |
458295 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[SDOI 2010] 猪国杀 |
最终得分 |
100 |
用户昵称 |
HZOI_蒟蒻一只 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2017-10-10 21:34:06 |
内存使用 |
0.00 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int maxn=50010;
int Bef[maxn],Nex[maxn],cnt;char Kind[maxn],Paidui[3010];
int top,m;
char Get_a_Card()
{
if(top!=m)top++;
return Paidui[top];
}
int Real_Identity[15],Tot_Enemy;
bool Is_Game_Over;int Now_Round;
void Kill_Another_Player(int,int);
void Get_Into_A_Fight_With_Another_Player(int,int);
void Seek_For_A_Kill_From_Everyone(int);
void Seek_For_A_Evasion_From_Everyone(int);
class pig
{
public:
int Current_Identity,Head,Last,Now,Iter;
int Blood,Unassailable_Num,Heart_Num,Evasion_Num;
int Att_Target,Las_Player,Nex_Player;
bool Is_Dead,Equipped_Arrow;
int ID_num;
void Print_Cards()
{
int Now=Head;cout<<Blood<<endl;
while(Now)cout<<Kind[Now],Now=Nex[Now];
cout<<endl;
}
void Get_Bonus_After_Killing_An_Enemy()
{
cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last;
if(!Head)Head=Last=cnt;
else Nex[Last]=cnt,Last=cnt;
switch(Kind[cnt])
{
case 'J':Unassailable_Num++;break;
case 'P':Heart_Num++;break;
case 'D':Evasion_Num++;break;
}
cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last,Nex[Last]=cnt,Last=cnt;
switch(Kind[cnt])
{
case 'J':Unassailable_Num++;break;
case 'P':Heart_Num++;break;
case 'D':Evasion_Num++;break;
}
cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last,Nex[Last]=cnt,Last=cnt;
switch(Kind[cnt])
{
case 'J':Unassailable_Num++;break;
case 'P':Heart_Num++;break;
case 'D':Evasion_Num++;break;
}
}
void Get_Punish_After_Killing_An_Teammate()
{
Head=Last=Now=0;
Unassailable_Num=Heart_Num=Evasion_Num=0;
Equipped_Arrow=0;
}
void Stage_When_A_Player_Get_Cards()
{
cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last;
if(!Head)Head=Last=cnt;
else Nex[Last]=cnt,Last=cnt;
switch(Kind[cnt])
{
case 'J':Unassailable_Num++;break;
case 'P':Heart_Num++;break;
case 'D':Evasion_Num++;break;
}
cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last,Nex[Last]=cnt,Last=cnt;
switch(Kind[cnt])
{
case 'J':Unassailable_Num++;break;
case 'P':Heart_Num++;break;
case 'D':Evasion_Num++;break;
}
}
void Stage_When_A_Player_Tries_To_Use_A_Card(int x)
{
switch(Kind[x])
{
case 'J':Unassailable_Num--;break;
case 'P':Heart_Num--;break;
case 'D':Evasion_Num--;break;
}
if(x==Head&&x==Last)Head=Last=0;
else if(x==Head)Head=Nex[x],Bef[Nex[x]]=0;
else if(x==Last)Last=Bef[x],Nex[Bef[x]]=0;
else Bef[Nex[x]]=Bef[x],Nex[Bef[x]]=Nex[x];
}
char Show_A_Players_Next_Card()
{
if(!Now)return 0;
Iter=Now;Now=Nex[Now];
return Kind[Iter];
}
void Output_The_Final_Answer()
{
if(Is_Dead)puts("DEAD");
else
{
while(Head)
{
cout<<Kind[Head];
if(Head!=Last)putchar(' ');
Head=Nex[Head];
}
puts("");
}
}
int Get_The_ID_Of_The_First_Evasion()
{
Now=Head;char tmp;
while(tmp=Show_A_Players_Next_Card())
if(tmp=='D')return Iter;
}
int Get_The_ID_Of_The_First_Heart()
{
Now=Head;char tmp;
while(tmp=Show_A_Players_Next_Card())
if(tmp=='P')return Iter;
}
int Get_The_ID_Of_The_First_Unassailable()
{
Now=Head;char tmp;
while(tmp=Show_A_Players_Next_Card())
if(tmp=='J')return Iter;
}
bool Try_To_Use_A_Kill()
{
Now=Head;char tmp;
while(tmp=Show_A_Players_Next_Card())
if(tmp=='K'){Stage_When_A_Player_Tries_To_Use_A_Card(Iter);return 1;}
return 0;
}
bool Try_To_Use_A_Evasion()
{
if(Evasion_Num){Stage_When_A_Player_Tries_To_Use_A_Card(Get_The_ID_Of_The_First_Evasion());return 1;}
return 0;
}
bool Try_To_Use_A_Heart()
{
if(Heart_Num){Stage_When_A_Player_Tries_To_Use_A_Card(Get_The_ID_Of_The_First_Heart());return 1;}
return 0;
}
bool Try_To_Use_A_Unassailable()
{
if(Unassailable_Num){Stage_When_A_Player_Tries_To_Use_A_Card(Get_The_ID_Of_The_First_Unassailable());return 1;}
return 0;
}
void One_Players_Round()
{
Stage_When_A_Player_Get_Cards();
Now=Head;char tmp;bool Kill_Has_Used=0;
while((tmp=Show_A_Players_Next_Card())&&!Is_Game_Over)
{
switch(tmp)
{
case 'D':break;
case 'J':break;
case 'P':if(Blood!=4)Blood++,Stage_When_A_Player_Tries_To_Use_A_Card(Iter);break;
case 'K':if(Att_Target==Nex_Player)
if(!Kill_Has_Used||Equipped_Arrow)
{
Stage_When_A_Player_Tries_To_Use_A_Card(Iter),Kill_Another_Player(ID_num,Att_Target);
Now=Head;Kill_Has_Used=1;
if(Is_Game_Over)return;
}
break;
case 'F':if(!Att_Target)break;
Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
if(Real_Identity[ID_num]==3)Get_Into_A_Fight_With_Another_Player(ID_num,1);
else Get_Into_A_Fight_With_Another_Player(ID_num,Att_Target);
if(Is_Game_Over||Is_Dead)return;
Now=Head;
break;
case 'N':Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
Seek_For_A_Kill_From_Everyone(ID_num);Now=Head;
if(Is_Game_Over)return;
break;
case 'W':Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
Seek_For_A_Evasion_From_Everyone(ID_num);Now=Head;
if(Is_Game_Over)return;
break;
case 'Z':Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
Equipped_Arrow=1;Now=Head;break;
}
}
}
}Players[11];
void Refresh_The_Infection_Of_One_Player_In_Everyones_Mind(int x)
{
int y=Players[x].Nex_Player;
switch(Real_Identity[x])
{
case 1:while(y!=x)
{
if(Players[y].Current_Identity==1||Players[y].Current_Identity==3){Players[x].Att_Target=y;return;}
y=Players[y].Nex_Player;
}
Players[x].Att_Target=0;break;
case 2:while(y!=x)
{
if(Players[y].Current_Identity==3){Players[x].Att_Target=y;return;}
y=Players[y].Nex_Player;
}
Players[x].Att_Target=0;break;
case 3:while(y!=x)
{
if(Players[y].Current_Identity==2||Real_Identity[y]==1){Players[x].Att_Target=y;return;}
y=Players[y].Nex_Player;
}
Players[x].Att_Target=0;
}
}
void Every_Player_Try_To_Refresh_Their_Infection()
{
int x=Players[1].Nex_Player;Refresh_The_Infection_Of_One_Player_In_Everyones_Mind(1);
while(x!=1)Refresh_The_Infection_Of_One_Player_In_Everyones_Mind(x),x=Players[x].Nex_Player;
}
void A_Player_Was_Killed_By_Another_One(int x,int y)
{
Players[y].Is_Dead=1;
if(Real_Identity[y]==1){Is_Game_Over=1;return;}
if(Real_Identity[y]==3)
{
Tot_Enemy--;
if(!Tot_Enemy){Is_Game_Over=1;return;}
Players[x].Get_Bonus_After_Killing_An_Enemy();
}
if(Real_Identity[y]==2&&Real_Identity[x]==1)Players[x].Get_Punish_After_Killing_An_Teammate();
int BEFO=Players[y].Las_Player,NEXT=Players[y].Nex_Player;
Players[BEFO].Nex_Player=NEXT,Players[NEXT].Las_Player=BEFO;
Every_Player_Try_To_Refresh_Their_Infection();
}
void A_Player_Was_Wounded_By_Another_One(int x,int y)
{
Players[y].Blood--;
if(!Players[y].Blood)
if(Players[y].Try_To_Use_A_Heart())Players[y].Blood++;
else A_Player_Was_Killed_By_Another_One(x,y);
}
void Kill_Another_Player(int x,int y)
{
if(Real_Identity[x]!=1&&Players[x].Current_Identity<2)
{
if(Real_Identity[y]==3)Players[x].Current_Identity=2;
else Players[x].Current_Identity=3;
Every_Player_Try_To_Refresh_Their_Infection();
}
if(Players[y].Try_To_Use_A_Evasion())return;
A_Player_Was_Wounded_By_Another_One(x,y);
}
bool Start_An_Unassailable_Cycle(int st,bool Is_He_An_Enemy)
{
bool ST=Is_He_An_Enemy;int Last_One_Who_Show_An_Unassailble=st,x=st;
if(Is_He_An_Enemy==(Real_Identity[x]==3))
if(Players[x].Try_To_Use_A_Unassailable())
{
Last_One_Who_Show_An_Unassailble=x,Is_He_An_Enemy^=1;
if(Players[x].Current_Identity<=2)Players[x].Current_Identity=3-Is_He_An_Enemy,Every_Player_Try_To_Refresh_Their_Infection();
}
x=Players[x].Nex_Player;
while(x!=Last_One_Who_Show_An_Unassailble)
{
if(Is_He_An_Enemy==(Real_Identity[x]==3))
if(Players[x].Try_To_Use_A_Unassailable())
{
Last_One_Who_Show_An_Unassailble=x,Is_He_An_Enemy^=1;
if(Players[x].Current_Identity<=2)Players[x].Current_Identity=3-Is_He_An_Enemy,Every_Player_Try_To_Refresh_Their_Infection();
}
x=Players[x].Nex_Player;
}
return (ST!=Is_He_An_Enemy);
}
void Get_Into_A_Fight_With_Another_Player(int x,int y)
{
if(Real_Identity[x]!=1&&Players[x].Current_Identity<2)
{
if(Real_Identity[y]==3)Players[x].Current_Identity=2;
else Players[x].Current_Identity=3;
Every_Player_Try_To_Refresh_Their_Infection();
}
if(Real_Identity[y]==1||Players[y].Current_Identity>=2)
{
if(Real_Identity[y]==1||Players[y].Current_Identity==2)
{
if(Start_An_Unassailable_Cycle(x,0))return;
}
else if(Start_An_Unassailable_Cycle(x,1))return;
}
if(Real_Identity[x]==1&&Real_Identity[y]==2)A_Player_Was_Wounded_By_Another_One(x,y);
else while(1)
{
if(!Players[y].Try_To_Use_A_Kill()){A_Player_Was_Wounded_By_Another_One(x,y);return;}
if(!Players[x].Try_To_Use_A_Kill()){A_Player_Was_Wounded_By_Another_One(y,x);return;}
}
}
void Seek_For_A_Kill_From_Everyone(int x)
{
int y=Players[x].Nex_Player;
while(y!=x)
{
if(Real_Identity[y]==1||Players[y].Current_Identity>=2)
{
if(Real_Identity[y]==1||Players[y].Current_Identity==2)
{
if(Start_An_Unassailable_Cycle(x,0)){y=Players[y].Nex_Player;continue;}
}
else if(Start_An_Unassailable_Cycle(x,1)){y=Players[y].Nex_Player;continue;}
}
if(!Players[y].Try_To_Use_A_Kill())
{
A_Player_Was_Wounded_By_Another_One(x,y);
if(Is_Game_Over)return;
if(y==1&&Players[x].Current_Identity==0)Players[x].Current_Identity=1,Every_Player_Try_To_Refresh_Their_Infection();
}
y=Players[y].Nex_Player;
}
}
void Seek_For_A_Evasion_From_Everyone(int x)
{
int y=Players[x].Nex_Player;
while(y!=x)
{
if(Real_Identity[y]==1||Players[y].Current_Identity>=2)
{
if(Real_Identity[y]==1||Players[y].Current_Identity==2)
{
if(Start_An_Unassailable_Cycle(x,0)){y=Players[y].Nex_Player;continue;}
}
else if(Start_An_Unassailable_Cycle(x,1)){y=Players[y].Nex_Player;continue;}
}
if(!Players[y].Try_To_Use_A_Evasion())
{
A_Player_Was_Wounded_By_Another_One(x,y);
if(Is_Game_Over)return;
if(y==1&&!Players[x].Current_Identity)Players[x].Current_Identity=1,Every_Player_Try_To_Refresh_Their_Infection();
}
y=Players[y].Nex_Player;
}
}
int haha()
{
freopen("kopk.in","r",stdin);
freopen("kopk.out","w",stdout);
int n;scanf("%d%d",&n,&m);
int x=0;char opt[10];
for(int i=1;i<n;i++)Players[i].Nex_Player=i+1;Players[n].Nex_Player=1;
Players[1].Las_Player=n;for(int i=2;i<=n;i++)Players[i].Las_Player=i-1;
for(int i=1;i<=n;i++)
{
scanf("%s",opt);
switch(opt[0])
{
case 'M':Real_Identity[i]=1;break;
case 'Z':Real_Identity[i]=2;break;
case 'F':Real_Identity[i]=3,Tot_Enemy++;break;
}
scanf("%s",opt),x++,Paidui[x]=opt[0];
scanf("%s",opt),x++,Paidui[x]=opt[0];
scanf("%s",opt),x++,Paidui[x]=opt[0];
scanf("%s",opt),x++,Paidui[x]=opt[0];
}
for(int i=1;i<=m;i++)scanf("%s",opt),x++,Paidui[x]=opt[0];
m+=4*n;
for(int i=1;i<=n;i++)
Players[i].Stage_When_A_Player_Get_Cards(),Players[i].Stage_When_A_Player_Get_Cards(),
Players[i].ID_num=i,Players[i].Blood=4;
int now=1;Every_Player_Try_To_Refresh_Their_Infection();
while(!Is_Game_Over)Now_Round=now,Players[now].One_Players_Round(),now=Players[now].Nex_Player;
if(Players[1].Is_Dead)puts("FP");else puts("MP");
for(int i=1;i<=n;i++)Players[i].Output_The_Final_Answer();
}
int sb=haha();
int main(){;}