luogu#P10216. 【模板】Pfaffian
【模板】Pfaffian
Background
A permutation of length is called a perfect matching if and only if it satisfies:
- .
- .
Let denote the number of inversions of , and . Let be the set of all perfect matchings of length .
Let be a skew-symmetric matrix. The of is defined as
$$\textup{Pf}(\mathbf{A})=\sum\limits_{\pi\in\mathfrak{M}_{2n}}(\textup{sgn }\pi)\prod\limits_{i=1}^{n}a_{\pi(2i-1),\pi(2i)}$$Problem Description
Given an even integer and a skew-symmetric matrix , find .
Input Format
The first line contains a positive integer , and it is guaranteed that is even.
The next lines describe the matrix. On the -th line, there are non-negative integers, where the -th integer represents .
Output Format
Output one non-negative integer, the answer.
4
1 2 3
4 5
6
8
Hint
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5