아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Pipeline Plans

시간 제한5초메모리 제한512 MB

요약
타일을 R×C 격자에 배치해 왼쪽 위 칸 중심과 오른쪽 아래 칸 중심이 도로로 이어지는 경우의 수를 센다.
난이도

보통10점 중 7점

유형
백트래킹, DFS, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

There are twelve types of tiles in Fig. 1. You were asked to fill a table with R × C cells with these tiles. R is the number of rows and C is the number of columns.

How many arrangements in the table meet the following constraints?

  • Each cell has one tile.

  • the center of the upper left cell (1,1) and the center of the lower right cell (C, R) are connected by some roads.

Fig. 1: the types of tiles

입력

The first line contains two integers R and C (2 ≤ R × C ≤ 15). You can safely assume at least one of R and C is greater than 1.

The second line contains twelve integers, t1, t2, ..., t12 (0 ≤ t1 + .... + t12 ≤ 15). ti represents the number of the i-th tiles you have.

출력

Output the number of arrangments in a line.

예제5

  1. 예제 1

    입력
    3 3
    4 2 2 0 0 0 0 0 0 0 0 1
    
    예상 출력
    2
    
  2. 예제 2

    입력
    3 3
    0 1 1 0 0 0 0 0 0 0 0 7
    
    예상 출력
    66
    
  3. 예제 3

    입력
    3 3
    0 0 0 0 0 0 0 0 0 0 0 10
    
    예상 출력
    1
    
  4. 예제 4

    입력
    2 4
    0 0 1 1 1 2 0 1 0 0 1 1
    
    예상 출력
    2012
    
  5. 예제 5

    입력
    5 2
    0 1 1 1 0 1 2 1 2 0 0 1
    
    예상 출력
    8512