#10812. [HAOI2016] 放棋子

    ID: 10812 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>高精度递推2016河南各省省选

[HAOI2016] 放棋子

Problem Description

Given an N×NN\times N matrix. Each row contains exactly one obstacle; it is guaranteed that no two obstacles are in the same row or the same column. You need to place NN pieces on this matrix (you cannot place a piece on a cell with an obstacle) such that each row contains exactly one piece and each column contains exactly one piece. Find the number of valid arrangements.

Input Format

The first line contains an integer NN, followed by an N×NN \times N matrix. N≤200N\leq 200. 00 denotes no obstacle, and 11 denotes an obstacle.

Output Format

A single integer, the number of valid arrangements.

2
0 1
1 0
1

Hint

Translated by ChatGPT 5