시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 3 1 1 33.333%

문제

백승환은 레고를 좋아한다. 레고를 쌓은 모습이 2가지 각도에서 주어졌을 때, 그렇게 만드는 경우의 수는 총 몇 가지가 있는지 구하는 프로그램을 작성하시오.

이 문제에서 승환이는 오직 2*2크기의 블록만 사용한다. 하지만, 이 블록은 흰색 (W), 회색 (G), 검정색 (B) 과 같이 총 3가지 색상이 있다. 승환이는 이 세가지 색상의 블록을 무수히 많이 가지고 있다. 승환이는 6*6크기의 보드에 레고를 꼽을 것이다. 모든 블록은 보드의 모서리에 평행해야 하고, 보드의 바깥으로 나가면 안된다. 그리고 블록은 떠있을 수 없다.

가장 왼쪽은 가능한 경우다. 한 블록이 다른 블록 위에 있기 때문이다. 하지만, 가운데는 블록이 떠있기 때문에 불가능한 경우다. 오른쪽은 6*6 보드를 넘어가므로 불가능한 경우다.

입력

입력의 첫째 줄에 H가 주어진다. H는 승환이가 만드려고 하는 것의 높이이다. 다음 H개의 줄에는 6개의 문자가 주어진다. 이것은 승환이가 만든 것을 한 쪽에서 봤을 때 (밑의 Hint 그림에서 A) 이다. 모든 문자는 W, G, B 또는 .이다. W, G, B는 블록의 색상이고, .은 빈 공간이다. 이 문제에서 각 블록의 깊이를 예측할 수 없는 것을 예상하고 문제를 풀어야 한다. 따라서 ,같은 색상이 인접해 있다고 해도, 같은 높이에 있는 블록이 아닐 수 있다. 그 다음 H줄에는 그림 상에서 B에 해당하는 곳에서 본 블록의 모양이 주어진다.

출력

첫째 줄에 문제의 정답을 출력한다. 이때, 어떤 두 가지 모양이 있다고 할 때, 하나를 A, 하나를 B라고 하자. 이때 B를 거울 대칭이나 회전을 해서 A를 만들 수 있다고 하면, 두 가지 모두 다른 경우로 세야 한다. 정답은 64비트 인트형에 항상 포함된다.

예제 입력 1

2
WWGG..
.BB.WW
.WGG..
WWGG..

예제 출력 1

6

힌트

W3sicHJvYmxlbV9pZCI6IjI0MjUiLCJwcm9ibGVt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BldmVuIGlmIHR3byBkaVx1ZmIwMGVyZW50IHBvc3NpYmxlIGNvbnN0cnVjdGlvbnMgY291bGQgYmUgb2J0YWluZWQgZnJvbSBlYWNoIG90aGVyIGJ5IHJvdGF0aW5nIG9yIG1pcnJvcmluZywgdGhleSBib3RoIHNob3VsZCBiZSBjb3VudGVkLiBGb3IgdGhlIGdpdmVuIGlucHV0LCB0aGUgYW5zd2VyIHdpbGwgYWx3YXlzIFx1ZmIwMXQgaW4gYSBzaWduZWQgNjQtYml0IGludGVnZXIuPFwvcD5cclxuIiwiaGludCI6IjxwPjxpbWcgYWx0PVwiXCIgc3JjPVwiXC9KdWRnZU9ubGluZVwvdXBsb2FkXC8yMDExMDdcL2xlZ28yKDEpLnBuZ1wiIHN0eWxlPVwiaGVpZ2h0OjEyNnB4OyB3aWR0aDoyMzVweFwiIFwvPjxcL3A+XHJcblxyXG48cD5PbmUgb2YgdGhlIHBvc3NpYmxlIGNvbnN0cnVjdGlvbnMgaW4gdGhlIGV4YW1wbGUuPFwvcD5cclxuIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2010 2번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: doju