标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 10509 | Accepted: 6786 |
1. WHITE x, y, L // Paint a white square on the board,
// the square is defined by left-top grid (x, y)
// and right-bottom grid (x+L-1, y+L-1)
2. BLACK x, y, L // Paint a black square on the board,
// the square is defined by left-top grid (x, y)
// and right-bottom grid (x+L-1, y+L-1)
3. TEST x, y, L // Ask for the number of black grids
// in the square (x, y)- (x+L-1, y+L-1)
5
BLACK 1 1 2
BLACK 2 2 2
TEST 1 1 3
WHITE 2 1 1
TEST 1 1 3
7
6
CODE:
#include <iostream> #include <cstdio> #include <cstring> #define REP(i, s, n) for(int i = s; i <= n; i ++) #define REP_(i, s, n) for(int i = n; i >= s; i --) using namespace std; int main(){ int T; scanf("%d", &T); int map[100 + 10][100 + 10]; memset(map, 0, sizeof(map)); char s[7]; while(T --){ scanf("%s", s); int x, y, l; scanf("%d%d%d", &x, &y, &l); if(s[0] == ‘B‘){ REP(i, x, x + l - 1) REP(j, y, y + l - 1) map[i][j] = 1; } else if(s[0] == ‘W‘){ REP(i, x, x + l - 1) REP(j, y, y + l - 1) map[i][j] = 2; } else if(s[0] == ‘T‘){ int ans = 0; REP(i, x, x + l - 1) REP(j, y, y + l - 1) if(map[i][j] == 1) ans ++; printf("%d\n", ans); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/ALXPCUN/p/4534950.html