题目描述
Alphago是全宇宙最知名的五子棋大师,作为五子棋菜鸟的你竟然向他发起挑战,你的终极目标就是胜利,尽早的实现5颗棋子连城一条线——五子连珠。现在棋局已经进行了一半,胜负尚未分出,下一步轮到你放棋子,这一颗棋子下去,你能否一招制胜下出五子连珠呢?(5颗连续排列的棋子,可以横着、竖着、或者45度角斜着均可)。
输入
输入14行字符串,每行字符串14个连续的字符。其中 . 代表棋盘上的空白格, * 代表你已经下的棋子,# 代表Alphago已经下的棋子。 数据保证待分析的棋局上没有任何一方已经存在五子连珠。
输出
如果这一步放完棋子你能实现五子连珠,那么你就胜利了,输出So Easy! 否则输出Alphago you are so good!
输出答案之后请输出回车换行。
样例输入
…#…#…
.…
……#…
……#…
……
……
…#…#…
.#……#
…
……#…
……
……#…
……
…#….#…
样例输出
So Easy!
提示
测试数据包括其他情况的案例。
#include <bits/stdc++.h>
using namespace std;
char c[15][15];
bool f=false;
int length=0,loop=1;
void dfs(int x,int y,int fx,int fy)
{
int tx=x+fx;
int ty=y+fy;
// cout<<tx<<" "<<ty<<endl;
if(c[tx][ty]=='*'&&length<4)
{
length++;
dfs(tx,ty,fx,fy);
}
else if(c[tx][ty]=='.'&&length<4&&loop)
{
length++;
loop--;
dfs(tx,ty,fx,fy);
}
else if(length==4&&loop&&c[tx][ty]=='.')
{
f=true;
}
else if(length==4&&c[tx][ty]=='*')
{
f=true;
}
}
int fx[9]={0,0,1,0,-1,-1,1,1,-1};
int fy[9]={0,1,0,-1,0,1,1,-1,-1};
int main()
{
for(int i=1;i<15;i++)
for(int j=1;j<15;j++)
cin>>c[i][j];
//输入
for(int i=1;i<15;i++)
{
for(int j=1;j<15;j++)
{
for(int k=1;k<9;k++)
{
if(c[i][j]=='*')
{
length=1;
loop=1;
dfs(i,j,fx[k],fy[k]);
if(f==true)
break;
}
}
}
}
if(f)cout<<"So Easy!"<<endl;
else cout<<"Alphago you are so good!"<<endl;
// cout<<dfs(4,6,1,0);
}