Connection Status:
Competition Arena > CubeBuilding
SRM 507 · 2010-11-01 · by ir5 · Dynamic Programming
Class Name: CubeBuilding
Return Type: int
Method Name: getCount
Arg Types: (int, int, int, int)
Problem Statement

Problem Statement

NOTE: This problem statement contains images that may not display properly if viewed outside of the applet.

Fox Ciel has R red cubes, G green cubes, and B blue cubes. The side length of each cube is 1. She is going to put all her cubes on a NxN board which is divided into 1x1 cells. Cubes must be placed within the cells, and a cell can contain a pile of multiple cubes.

The cubes that are placed on the board can be regarded as a "building". A "building" is called beautiful if and only if all visible cubes are the same color when viewing the building from the south, facing directly north.

In following figure, for example, left building is beautiful while right one is not.

Return the number of beautiful buildings she can make, modulo 1,000,000,007.

Constraints

  • R, G and B will each be between 0 and 25, inclusive.
  • The sum of R,G and B will be greater than or equal to 1.
  • N will be between 1 and 25, inclusive.
Examples
0)
1
0
1
2
Returns: 4

There are 4 possible beautiful buildings.

1)
1
1
2
1
Returns: 0

In this case, it is impossible to make beautiful buildings.

2)
2
2
1
3
Returns: 162
3)
0
0
10
12
Returns: 372185933
4)
1
1
1
2
Returns: 0

Submissions are judged against all 77 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class CubeBuilding with a public method int getCount(int R, int G, int B, int N) · 77 test cases · 2 s / 256 MB per case

Submitting as anonymous