Title: Two people take turns in the n*n of the parallelogram lattice into black and white two-color pieces,
If the black side can give the creation of a continuous line from 1~n lines then black wins, otherwise white wins.
Analysis: Graph theory, search. Use DFS or FloodFill solution to find solutions that can reach the low end from the top.
Description: Target 600 question ╮(╯▽╰)╭.
#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include < Cstdio> #include <cmath>using namespace Std;char maps[202][202];int dxy[6][2] = { -1,-1,-1,0,0,- 1,0,1,1,0,1,1};int dfs (int x, int y, int n) {if (x = = N) return 1;if (x < 0 | | x >= n | | y < 0 | | y >= N) retur N 0;if (maps[x][y]! = ' B ') return 0;maps[x][y] = ' # '; int max = 0;for (int k = 0; k < 6; + + k) Max |= Dfs (X+dxy[k][0], Y+dxy[k][1], n); return Max; }int Main () {int n,t = 1;while (~scanf ("%d", &n) && N) {for (int i = 0; i < n; + + i) scanf ("%s", maps[i]); int Flag = 0;for (int i = 0; i < n; + + i) if (maps[0][i] = = ' B ' && dfs (0, I, n)) flag = 1;printf ("%d", T + +); if (f LAG) printf ("b\n"), Else printf ("w\n");} return 0;}
UVa 260-il gioco dell ' X