AtCoder Grand Contest 059
C
Guessing Permutation for as Long as Possible
AtCoder
⌀ 2905
原题
← BD →
翻译中…

Problem Statement

翻译中…

A teacher has a hidden permutation $P=(P_1,P_2,\ldots,P_N)$ of $(1,2,\cdots,N)$. You are going to determine it.

翻译中…

To do this, you prepared a sequence of pairs of integers $(A_1,B_1),(A_2,B_2),\ldots,(A_{N(N-1)/2},B_{N(N-1)/2})$; this is a permutation of all pairs of the form $(a,b)$ ($1 \le a < b \le N$). Now, you will go over the pairs from the beginning. For a pair $(A_i, B_i)$, you will ask if $P_{A_i}<P_{B_i}$, and the teacher will tell you the answer. However, you will skip this question if you can already determine the answer to it from previous answers.

翻译中…

Find the number of permutations $P$, for which with your algorithm you will have to ask all $\frac{N(N-1)}{2}$ questions, modulo $10^9+7$.

翻译中…

Constraints

翻译中…
  • $2 \le N \leq 400$
  • $1 \le A_i < B_i \le N$
  • $(A_i,B_i) \neq (A_j,B_j)$ ($i \neq j$)
  • All values in the input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 B_1
A_2 B_2
\vdots
A_{N(N-1)/2} B_{N(N-1)/2}

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
2
1 2
Output #1
2
Clearly, for any permutation $P$, you need to ask $1$ question.
Input #2
4
1 2
1 3
2 3
2 4
3 4
1 4
Output #2
4
Consider $P=(2,3,1,4)$ as an example. In this case, you will skip the third question since you know $P_1 < P_2$ and $P_1 > P_3$ from previous questions and you can determine $P_2 > P_3$. Therefore, $P=(2,3,1,4)$ should not be counted.
Input #3
5
1 2
2 3
3 4
4 5
1 5
1 3
2 4
3 5
1 4
2 5
Output #3
0
题目信息
题号
agc059_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。