Fzu Mouse Button Simple Search

Source: Internet
Author: User

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

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.