Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5319
Test instructions: give you a square, a brush, two kinds of brush color method.
' \ ' indicates a red color along the diagonal, and '/' indicates a blue color along the diagonal. Blue Red Cross forms green;
Ask the minimum number of brushes to form a pattern.
Solution: Brush directly from top to bottom without being brushed.
Code:
#include <stdio.h>#include <ctime>#include <math.h>#include <limits.h>#include <complex>#include <string>#include <functional>#include <iterator>#include <algorithm>#include <vector>#include <stack>#include <queue>#include <set>#include <map>#include <list>#include <bitset>#include <sstream>#include <iomanip>#include <fstream>#include <iostream>#include <ctime>#include <cmath>#include <cstring>#include <cstdio>#include <time.h>#include <ctype.h>#include <string.h>#include <assert.h>using namespace STD;#define MAXN 156CharMAPS[MAXN][MAXN];intMain () {intT, N, I, J;scanf("%d", &t); while(t--) {scanf("%d", &n);intAns =0;memset(Maps,0,sizeof(maps)); for(i=1; i<=n; i++) {scanf('%s ', maps[i]+1); for(j=1; MAPS[I][J]; J + +) {if((maps[i][j] = =' B '|| MAPS[I][J] = =' G ') && maps[i-1][j+1] !=' B '&& maps[i-1][j+1] !=' G ') ans + +;if((maps[i][j] = =' R '|| MAPS[I][J] = =' G ') && maps[i-1][j-1] !=' R '&& maps[i-1][j-1] !=' G ') ans + +; } }printf("%d\n", ans); }return 0;}
Copyright NOTICE: Reprint please indicate the source.
Hdu 5319 Painter