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)