Title: give you a grid of points, and then give some links to the adjacent points of the operation (horizontal, vertical), statistics inside the square.
Analysis: Simulation. Use two arrays directly, record horizontal lines and vertical bars, and enumerate vertex scans when counted.
Note: Output a small ╮(╯▽╰)╭ first.
#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include < Cstdio> #include <cmath>using namespace Std;int h[10][10];int v[10][10];int main () {int n,m,x,y,t = 0;char C;whil E (~scanf ("%d%d", &n,&m)) {GetChar (); for (int i = 1; I <= n; + + i) for (int j = 1; J <= N; + + j) V[i][j] = H[I][J] = 0;for (int i = 1; I <= m; + + i) {scanf ("%c%d%d", &c,&x,&y); GetChar (); if (c = = ' H ') h[x][y] = 1;el Se v[y][x] = 1;} if (T + +) printf ("\n**********************************\n\n");p rintf ("Problem #%d\n\n", T); int sum = 0;for (int l = 1; l &L t;= N; + + L) {int count = 0,flag = 0;for (int i = 1; i+l <= N; + + i) for (int j = 1; j+l <= N; + + j) {flag = 1;for (int h = j; H < j+l; + + H) if (! H[i][h] | | ! H[I+L][H]) flag = 0;for (int v = i; v < i+l; + + V) if (! V[V][J] | | ! V[V][J+L]) flag = 0;count + = flag; Sum + = count;if (count) printf ("%d square (s) of size%d\n", count,l);} if (!sum) printf ("No completed SquaRes can be found.\n ");} return 0;}
UVa 201-squares