Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water (‘W’) or dry land (’.’). Farmer John would like to figure out how...
后来看了挑战程序设计,才知道大牛用的两层循环解决,,而且是是把遍历后的'W'改成'.'而不是像我一样另外设置一个flag数组(既麻烦又容易错),大牛,,这种小地方在比赛中时往往可以拉开差距 1. #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; char map[101]...
include<iostream> using namespace std;define MAX 100 char rectangle[MAX][MAX] = {'0'};void dfs(int i, int j, int N, int M){ if(rectangle[i][j] == '.' || i >= N || j >= M || i < 0 || j < 0)return ;rectangle[i][j] = '.';dfs(i - 1, j, N,...
private static CDriverModleList sCompatibleCDriverModle; private static CMesaLibList sCompatibleCMesaLibs; private static LanguagesList sCompatibleLanguages; private static RenderersList sCompatibleRenderers; @@ -1217,4 +1223,100 @@ public static void releaseRenderersCache() { sCompatibleRenderers =...
#include<cstdio>using namespace std; const int N=105; int n,m,ans,dir[8][2]={{0,1},{0,-1},{1,0},{-1,0},{-1,-1},{1,-1},{1,1},{-1,1}}; char mp[N][N]; void dfs(int x,int y){ mp[x][y]='.';
Input * Line 1: Two space-separated integers: N and M * Lines 2..N+1: M characters per line representing one row of Farmer John's field. Each character is either 'W' or '.'. The characters do not have spaces between them.
#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<stack>#defineMax 101usingnamespacestd;charmp[Max][Max];intn,m,vis[Max][Max],c;intdir[8][2] = {0,1,1,0,0,-1,-1,0,1,1,1,-1,-1,1,-1,-1};voiddfs(intx,inty) ...