luogu#P5241. 序列
序列
Problem Description
Build a directed graph with vertices, with no edges at the beginning.
Next, build an edge sequence of length . Each edge in the sequence is a directed edge satisfying and , and all edges in the sequence are distinct.
Add these edges to in order. After each addition, compute and record the current number of strongly connected components in the graph, obtaining a new positive integer sequence of length .
- If two edge sequences produce the same , then they are called essentially the same.
How many essentially different edge sequences are there? You only need to output the answer modulo .
Input Format
Input one line containing a positive integer , which denotes the number of vertices in the directed graph .
Output Format
Output one line containing integers separated by spaces. The -th number represents the answer when .
3
1 2 4 7 7 7
Hint
Subtask 1 (5pts): .
Subtask 2 (10pts): .
Subtask 3 (15pts): .
Subtask 4 (15pts): .
Subtask 5 (15pts): .
Subtask 6 (20pts): .
Subtask 7 (20pts): No special constraints.
Constraints: For all data, .
For the first subtasks, the time limit is , and for the -th it is .
Code length limit: 10kb. If it exceeds this limit, it will be marked as invalid after the contest.
Translated by ChatGPT 5