hey guys! can u explain why I can ignore the exact positions of the rooks in the initial configurations and that only the number of free rows and columns matter.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 166 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
hey guys! can u explain why I can ignore the exact positions of the rooks in the initial configurations and that only the number of free rows and columns matter.
Name |
---|
You simply can imagine it as a checkered square field and after you cut out a row or column you put the pieces back together and get the same, but just smaller square field. It perfectly shows why the order doesn't matter.
Look at it this way. A configuration is valid if no two rooks share the same column or row. So given that there are n rows and n columns, and a rook uses up one row and one column, it doesn't really matter which row and which columns it uses, since you will have left n-1 rows and n-1 columns. Notice that once you are actually solving the problem, the position actully matters while counting because you might count choosing [(3,1) then (2,4)] and [(2,4) then (1,3)] as diferent configurations, but that's the fun part of the problem.
In a more computational way, a configuration of rooks is a matching between the n rows and the m columns, so by adding an edge between row x and column y (putting a rook in (x,y)) you are left with a match between n-1 rows and n-1 columns and in the counting it doesn't really matter which are this columns/rows [again watch out for repetition, and in the case of this problem, how choosing one edge, the computer will choose another]