hdu5546 Ancient Go Simple Deep Search

Source: Internet
Author: User

Direct search ' o ' around there '. ' Some words can kill in one move!!!,

No on can not kill in one move!!!。

Water problem ...

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace
Std
Char a[15][15];
int vis[15][15];
int fx[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
	int dfs (int y,int x) {vis[y][x]=1;
	int flag=0;
		for (int i=0;i<4;++i) {int ty=y+fx[i][1];
		
		int tx=x+fx[i][0];
		
		if (Vis[ty][tx]) continue;
		if (a[ty][tx]== '. ')
			{flag++;
		Vis[ty][tx]=1;
	} else if (a[ty][tx]== ' O ') Flag+=dfs (TY,TX);
	}//cout<<flag<< "" <<y<< "" <<x<<endl;
return flag;
	} int main () {int n;
	cin>>n;
	int ca=1;
	 while (n--) {int flag=0;
	     
	 for (int. i=0;i<=n+1;++i) for (int j=0;j<=n+1;++j) a[i][j]= ' 1 ';
	      
	      
	 for (int i=1;i<=9;++i) for (int j=1;j<=9;++j) cin>>a[i][j];
		 for (int i=1;i<=9;++i) for (int j=1;j<=9;++j) if (a[i][j]== ' O ') {//cout<< "he";
		 	memset (vis,0,sizeof (VIS));
		 if (Dfs (I,J) <=1) flag=1; } cout<<"
	Case # "<<ca++<<": "; if (flag) cout<< "Can kill in one move!!!"
	<<endl; else cout<< "Can not kill in one move!!!"
    <<endl;  }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.