Young diagrams and Young tableaux
Time limit3sMemory limit128 MB
Count the fillings of the given Young diagram with numbers 1 to N that rise weakly across rows and strictly down columns.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Backtracking
- Solved
- No attempts yet
Problem
A Young diagram is an arrangement of boxes that satisfies the following conditions.
- The boxes are contiguous in every row and in every column.
- Every row is aligned to the leftmost column.
- No row is longer than the row directly above it.
An arrangement whose row lengths from top to bottom are 3, 2, 2, 1 is a Young diagram.
[][][]
[][]
[][]
[]
A Young tableau fills the boxes of a Young diagram with numbers under the following conditions.
- Each box holds an integer from 1 to , both ends allowed.
- The integer in a box is greater than or equal to the integer in the box directly to its left.
- The integer in a box is greater than the integer in the box directly above it.
With and row lengths 3, 2, 1, the arrangement below satisfies all three conditions.
1 1 2
2 3
3
Given and the shape of a Young diagram, write a program that computes the number of ways to build a Young tableau.
Input
The input holds several test cases and continues to the end of the file. Each test case takes two lines.
The first line gives the shape of the Young diagram. The leading integer is the number of rows, with . Then come integers , the box count of each row, satisfying .
The second line gives , with .
Output
For each test case, print the number of Young tableaux that can be built, one per line.