Logo
(追記) (追記ここまで)

18156번 - Black and White 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB23018515882.723%

문제

You are given an n-by-n grid where each square is colored either black or white. A grid is correct if all of the following conditions are satisfied:

  • Every row has the same number of black squares as it has white squares.
  • Every column has the same number of black squares as it has white squares.
  • No row or column has 3 or more consecutive squares of the same color.

Given a grid, determine whether it is correct.

입력

The first line contains an integer n (2 ≤ n ≤ 24; n is even). Each of the next n lines contains a string of length n consisting solely of the characters ‘B’ and ‘W’, representing the colors of the grid squares.

출력

If the grid is correct, print the number 1 on a single line. Otherwise, print the number 0 on a single line.

제한

예제 입력 1

4
WBBW
WBWB
BWWB
BWBW

예제 출력 1

1

예제 입력 2

4
BWWB
BWBB
WBBW
WBWW

예제 출력 2

0

예제 입력 3

6
BWBWWB
WBWBWB
WBBWBW
BBWBWW
BWWBBW
WWBWBB

예제 출력 3

0

예제 입력 4

6
WWBBWB
BBWWBW
WBWBWB
BWBWBW
BWBBWW
WBWWBB

예제 출력 4

1

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2019 ICPC Pacific Northwest Region > Division 2 W번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /