Graph Game
Time limit2sMemory limit1024 MB
Count the number of distinct directed graphs on n labeled vertices that can arise as positions in a game where each move adds an edge without creating a cycle.
- Level
Hard9 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Graph
- Solved
- No attempts yet
Problem
Petya and Vasya play another interesting game. They have a sheet of paper with circles drawn on it, labeled with the numbers from to . The players take turns drawing arrows that connect circles. An arrow from circle to circle may be drawn if two conditions hold:
- there is no arrow from to yet;
- one cannot reach from by following arrows.
For example, in the position in Figure 1 one can draw one of three arrows (Figure 2).
The player who cannot make a move loses.
Petya decided to write a program that plays this game. To do so, he first wants to count how many different positions can appear on the board.
Input
The input file contains a single number ().
Output
Output to the output file the number of possible positions, without leading zeros.
Notes
Here are all 25 possible positions for the example from the statement:


