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

14053번 - O Canada 다국어

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

문제

In this problem, a grid is an N-by-N array of cells, where each cell is either red or white.

Some grids are similarto other grids. Grid A is similar to grid B if and only if A can be transformed into B by some sequence of changes. A change consists of selecting a 2-by-2 square in the grid and flipping the colour of every cell in the square. (Red cells in the square will become white; white cells in the square will become red.)

You are given G grids. Count the number of pairs of grids which are similar. (Formally, number the grids from 1 to G, then count the number of tuples (i, j) such that 1 ≤ i < j ≤ G and grid i is similar to grid j.)

입력

The first line of input contains N (2 ≤ N ≤ 10), the size of the grids. The second line contains G (2 ≤ G ≤ 10000), the number of grids. The input then consists of N · G lines, where each line contains N characters, where each character is either R or W, indicating the colour (red or white) for that element in the grid. Moreover, after the first two lines of input, the next N lines describe the first grid, the following N lines describe the second grid, and so on.

출력

Output the number of pairs of grids which are similar.

제한

예제 입력 1

2
2
RW
WR
WR
RW

예제 출력 1

1

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2016 > CCO 2016 4번

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

출처

대학교 대회

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

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