Problem H: Little volcano's go dream multi-school training 2 (small volcano session)

Source: Internet
Author: User

Title Link: http://acm.zzuli.edu.cn/zzuliacm/problem.php?id=1908

Test instructions: if '. ' Surrounded by ' * ', put '. ' Into ' * '.

Analysis: If it is ' * ' direct output, if it is '. ' Then you want to search for it

If the four directions are closed, you can change them. namely w[i][j]=4;

If the query is ' * ' or the query is already queried '. ' , the record is on;

If the query is '. ' And no query marked, then the query;

1#include <iostream>2#include <algorithm>3#include <cstdio>4#include <cstring>5#include <queue>6#include <stdlib.h>7#include <map>8#include <cmath>9 Ten using namespacestd; One  A #defineN 50 - #defineINF 0x3f3f3f3f -  the CharS[n][n]; - intw[n][n],b[n][n],n,m; - intdir[4][2]= { {1,0},{0,1},{-1,0},{0,-1} }; -  + intQintXinty) - { +     inti; A  atb[x][y]=1; -      for(i=0; i<4; i++) -     { -         intxx=x+dir[i][0]; -         intyy=y+dir[i][1]; -         if(xx>=0&&xx<n&&yy>=0&&yy<m&& (s[xx][yy]=='*'||B[xx][yy])) inw[x][y]++; -         if(xx>=0&&xx<n&&yy>=0&&yy<m&&s[xx][yy]=='.'&&!B[xx][yy]) to         { +             if(q (xx,yy) = =1) -w[x][y]++; the         } *     } $ Panax Notoginseng     if(w[x][y]==4) -         return 1; the     return 0; + } A  the intMain () + { -     intt,k=1, I,j; $  $scanf"%d", &T); -  -      while(t--) the     { -Memset (W,0,sizeof(w));Wuyi  thescanf"%d%d", &n,&m); -  Wu          for(i=0; i<n; i++) -scanf"%s", S[i]); About  $printf"Case %d:\n", k++); -  -          for(i=0; i<n; i++) -         { A              for(j=0; j<m; J + +) +             { the                 if(s[i][j]=='.') -                 { $Memset (W,0,sizeof(w)); thememset (b,0,sizeof(b)); the  the                     if(q (i,j) = =1) thes[i][j]='*'; -                 } in  theprintf"%c", S[i][j]); the             } Aboutprintf"\ n"); the         } the     } the     return 0; +}

Problem H: Little volcano's go dream multi-school training 2 (small volcano session)

Related Article

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.