Skip to content

Instantly share code, notes, and snippets.

@Abreto
Created October 11, 2012 11:55
Show Gist options
  • Save Abreto/3871850 to your computer and use it in GitHub Desktop.
Save Abreto/3871850 to your computer and use it in GitHub Desktop.
PKU 1656 - Counting Black
/* PKU 1656 - Counting Black. */
#include <stdio.h>
#include <string.h>
int main(void)
{
int i = 0, m = 0;
int t = 0;
char command[6] = " ";
int x = 0, y = 0, L = 0;
char board[100][100] = {{0}};
scanf("%d", &t);
while(t--)
{
scanf("%s %d %d %d", command, &x, &y, &L);
if( strcmp(command, "WHITE") == 0 )
{
for(i = x-1;i < x+L-1;i++)
for(m = y-1;m < y+L-1;m++)
board[i][m] = 0;
} else if (strcmp(command, "BLACK") == 0) {
for(i = x-1;i < x+L-1;i++)
for(m = y-1;m < y+L-1;m++)
board[i][m] = 1;
} else {
int count = 0;
for(i = x-1;i < x+L-1;i++)
for(m = y-1;m < y+L-1;m++)
count += (int)(board[i][m]1);
printf("%d\n", count);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment