Test instructions is the minimum number of mine clearance to open the map point ...
The idea is also very obvious is the first to put all the marks once all the points ...
Input diagram ...
All thunder is not marked ...
After that, traverse the graph ...
Then hit 0 to search a lap hit the number on the mark ...
Not difficult, but the card for a long time ...
Directly on the code ...
#include <stdio.h>#include<string.h>Chars[ A][ A];BOOLvis[ A][ A];intN;intdx[Ten]={0,0,1,-1,1,-1,1,-1};intdy[Ten]={1,-1,0,0,-1,1,1,-1};voidDfsintXinty) { if(!vis[x][y])return ; if(x<1&&x>n&&y<1&&y>n)return ; Vis[x][y]=false; if(s[x][y]!='0')return ; Else{ for(intI=0;i<8; i++) DFS (x+dx[i],y+Dy[i]); }}intMain () {intT; scanf ("%d",&T); intTime=1; while(t--) {scanf ("%d",&N); memset (Vis,true,sizeof(VIS)); Charss[ A]; for(intI=1; i<=n;i++) {scanf ("%s", SS); for(intj=0; j<n;j++) {s[i][j+1]=Ss[j]; if(s[i][j+1]=='@') vis[i][j+1]=false; } } /*puts (""); for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {printf ("%c", S[i][j]); } puts (""); } puts ("");*/ intsum=0; for(intI=1; i<=n;i++){ for(intj=1; j<=n;j++){ if(s[i][j]=='0'&&Vis[i][j]) {Sum++; DFS (I,J); } } } /*for (int i=1;i<=n;i++) {for (int j=1;j<=n;j++) {printf ("%c", vis[i][j]? ' 1 ': ' 0 '); } puts (""); }*/ for(intI=1; i<=n;i++) for(intj=1; j<=n;j++) if(Vis[i][j]) sum++; printf ("Case %d:%d\n", time++, sum); } return 0;}
Fzu Mouse Button Simple Search