细心细心细心 认真读题
这道题目其实很水,但是我还是要把它记录下来,因为这道题让我认识到了认真读题的重要性
因为没有认真读题,前前后后wa了13次,真的醉了,其实把题目的要求看清楚很容易ac
直接暴搜就可以
#include<iostream>
#include<cstring>
using namespace std;
int flag;
int dic[4][2]= {{-1,1},{1,0},{1,1},{0,1}};
int ans_x,ans_y;
int num[21][21];
void dfs()
{
int aa=0;
for(int x=1; x<=19&&!flag; x++)
{
for(int y=1; y<=19&&!flag; y++)
{
if(num[x][y]==0)
continue;
for(int i=0; i<4; i++)
{
int j=0;
int dx=x;
int dy=y;
while(1)
{
dx=dx+dic[i][0];
dy=dy+dic[i][1];
if(num[x][y]!=num[dx][dy]||dx<=0||dx>19||dy<=0||dy>19)
break;
j++;
}
if(j==4&&num[x-dic[i][0]][y-dic[i][1]]!=num[x][y])
{
if(num[x][y]==1)
flag=1;
if(num[x][y]==2)
flag=2;
ans_x=x;
ans_y=y;
break;
}
}
}
}
}
int main()
{
int T;
cin>>T;
while(T--)
{
memset(num,0,sizeof(num));
for(int i=1; i<=19; i++)
for(int j=1; j<=19; j++)
cin>>num[i][j];
flag=0;
dfs();
if(flag==0)
cout<<"0\n";
if(flag==1)
{
cout<<flag<<endl;;
cout<<ans_x<<" "<<ans_y<<endl;
}
if(flag==2)
{
cout<<flag<<endl;
cout<<ans_x<<" "<<ans_y<<endl;
}
}
}
仅以此题,献给我的13次wa