시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
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

힌트

W3sicHJvYmxlbV9pZCI6IjI0MjUiLCJwcm9ibGV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BOb3RlIHRoYXQgZXZlbiBpZiB0d28gZGlcdWZiMDBlcmVudCBwb3NzaWJsZSBjb25zdHJ1Y3Rpb25zIGNvdWxkIGJlIG9idGFpbmVkIGZyb20gZWFjaCBvdGhlciBieSByb3RhdGluZyBvciBtaXJyb3JpbmcsIHRoZXkgYm90aCBzaG91bGQgYmUgY291bnRlZC4gRm9yIHRoZSBnaXZlbiBpbnB1dCwgdGhlIGFuc3dlciB3aWxsIGFsd2F5cyBcdWZiMDF0IGluIGEgc2lnbmVkIDY0LWJpdCBpbnRlZ2VyLjxcL3A+XHJcbiIsImhpbnQiOiI8cD48aW1nIGFsdD1cIlwiIHNyYz1cIlwvSnVkZ2VPbmxpbmVcL3VwbG9hZFwvMjAxMTA3XC9sZWdvMigxKS5wbmdcIiBzdHlsZT1cImhlaWdodDoxMjZweDsgd2lkdGg6MjM1cHhcIiBcLz48XC9wPlxyXG5cclxuPHA+T25lIG9mIHRoZSBwb3NzaWJsZSBjb25zdHJ1Y3Rpb25zIGluIHRoZSBleGFtcGxlLjxcL3A+XHJcbiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2010 2번

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