Nice Array
Time limit2sMemory limit512 MB
Count ways to fill the erased cells of an N by N array so that every permutation's diagonal sum is equal, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Combinatorics, Math, Implementation
- Solved
- No attempts yet
Problem
You are given an array and a permutation of the integers from to .
An array is nice if is the same no matter which permutation you pick.
Some cells of have been erased. Write a program that counts the ways to fill in every erased cell so that the array is nice. Two ways are different if the finished arrays differ in at least one cell.
Input
The first line has the size () of the array .
Each of the next lines has one row of as characters with no spaces. An erased cell is -, and every other cell is an integer between and .
Output
Print the number of ways to make the array nice, modulo 1,000,000,007, on the first line.
A number you fill in is an integer that is at least , and it may be larger than . No input has an infinite number of ways.