[SWEA] 6731 홍익이의 오델로 게임

Time Lapse :47min 14sec

6731.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <memory.h>
char board[1000][1001];
int black_col[1000], black_row[1000];
int main(int argc, char** argv){
int tc, T, N,row,col,answer;
scanf("%d",&T);
for(tc=1;tc<=T;tc++){
scanf("%d",&N);
memset(black_row,0,sizeof(black_row));
memset(black_col,0,sizeof(black_col));
for(row=0;row<N;row++){
scanf("%s",board[row]);
for(col=0;col<N;col++){
if(board[row][col]=='B') {
black_col[row]++;
black_row[col]++;
}
}
}
answer = 0;
for(row=0;row<N;row++){
for(col=0;col<N;col++){
if(board[row][col]=='B'&&(black_row[col]+black_col[row]-1)&1)
++answer;
else if(board[row][col]=='W'&&(black_row[col]+black_col[row])&1)
++answer;
}
}
printf("#%d %d\n",tc,answer);
}
return 0; //정상종료시 반드시 0을 리턴해야 합니다.
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/6731/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.