比赛 |
20120722 |
评测结果 |
AAATTWTTAT |
题目名称 |
杀手游戏 |
最终得分 |
40 |
用户昵称 |
Truth.Cirno |
运行时间 |
5.002 s |
代码语言 |
C++ |
内存使用 |
13.67 MiB |
提交时间 |
2012-07-22 11:11:02 |
显示代码纯文本
#include <iostream>
#include <cstdio>
using namespace std;
int num,dui2[1000000],die;
char dui[1000000][10];
void swap(int& x,int& y)
{
int temp;
temp=x;
x=y;
y=temp;
}
void assi(void)//Ghost=0; Knife=1; Grenade=2; Bang=3; Miss=4; Parry=5;
{
int i;
die=2;
for (i=0;i<num;i++)
{
if (dui[i][0]=='G'&&dui[i][1]=='h')
dui2[i]=0;
else if (dui[i][0]=='K')
dui2[i]=1;
else if (dui[i][0]=='G'&&dui[i][1]=='r')
dui2[i]=2;
else if (dui[i][0]=='B')
dui2[i]=3;
else if (dui[i][0]=='M')
dui2[i]=4;
else// if (dui[i][0]=='P')
dui2[i]=5;
}
}
void play(void)
{
int i,j,k,hp[2]={4,4},cs[2]={4,4},shou[2][10],poi=0;
bool f,f2,ed;
for (i=0;i<4;i++)
shou[0][i]=dui2[poi++];
for (i=0;i<4;i++)
shou[1][i]=dui2[poi++];
for (i=0;i<=2;i++)
for (j=0;j<=2-i;j++)
if (shou[1][j]<shou[1][j+1])
swap(shou[1][j],shou[1][j+1]);
for (f=0,f2=1,ed=false;die==2;f=!f,f2=!f2,ed=false)
{
/*mo*/
for (i=0;i<2;i++)
shou[f][cs[f]++]=dui2[poi++];
for (i=0;i<=cs[f]-2;i++)
for (j=0;j<=cs[f]-2-i;j++)
if (shou[f][j]<shou[f][j+1])
swap(shou[f][j],shou[f][j+1]);
/*chu*/
for (i=cs[f]-1;i>=0;i--)
{
if (shou[f][i]==0)
{
for (j=cs[f2]-1;j>=0;j--)
if (shou[f2][j]==3)
break;
if (j>=0&&j<cs[f2])
{
cs[f2]--;
for (k=j;k<cs[f2];i++)
shou[f2][k]=shou[f2][k+1];
}
else
{
hp[f2]--;
if (!hp[f2])
{
die=f2;
break;
}
}
cs[f]--;
}
else if (shou[f][i]==1)
{
hp[f2]--;
if (!hp[f2])
{
die=f2;
break;
}
}
else if (shou[f][i]==2)
{
if (cs[f2]&&shou[f2][0]==4||cs[f2]&&shou[f2][0]==5)
{
if (shou[f2][0]==5)
{
shou[f2][0]=dui2[poi++];
for (j=1;j<cs[f2];j++)
if (shou[f2][0]>=shou[f2][j])
break;
j--;
swap(shou[f2][0],shou[f2][j]);
}
else
{
cs[f2]--;
for (j=0;j<cs[f2];j++)
shou[f2][j]=shou[f2][j+1];
}
}
else
{
hp[f2]--;
if (!hp[f2])
{
die=f2;
break;
}
}
cs[f]--;
}
else if (shou[f][i]==3&&!ed)
{
ed=true;
if (cs[f2]&&shou[f2][0]==4||cs[f2]&&shou[f2][0]==5)
{
if (shou[f2][0]==5)
{
shou[f2][0]=dui2[poi++];
for (j=1;j<cs[f2];j++)
if (shou[f2][0]>=shou[f2][j])
break;
j--;
swap(shou[f2][0],shou[f2][j]);
}
else
{
cs[f2]--;
for (j=0;j<cs[f2];j++)
shou[f2][j]=shou[f2][j+1];
}
}
else
{
hp[f2]--;
if (!hp[f2])
{
die=f2;
break;
}
}
cs[f]--;
}
else
{
/*qi*/
if (cs[f]>hp[f])
cs[f]=hp[f];
break;
}
}
}
}
int main(void)
{
freopen("bang.in","r",stdin);
freopen("bang.out","w",stdout);
bool over=false;
cin>>dui[0];
if (dui[0][0]=='.')
over=true;
while (!over)
{
num=1;
while (dui[num-1][0]!='=')
cin>>dui[num++];
num--;
assi();
play();
if (die==1)
printf("WIN\n");
else
printf("LOSE\n");
cin>>dui[0];
if (dui[0][0]=='.')
over=true;
}
return(0);
}