W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
A tournament is a directed graph in which:
Let's take the set of vertices and the permutation : , , , . There are only four tournaments for which this permutation is an automorphism:
Write a program which:
In the first line of the standard input there is one integer , , which is the number of vertices. In the following lines there is a description of a permutation . We assume that vertices are numbered from 1 to . In line there is a value of the permutation for the vertex (i.e. the value ).
In the first and only line of the standard output there should be one integer equal to the remainder of dividing (the number of different -vertex tournaments for which is an automorphism) by .
For the input data:
4 2 4 3 1
the correct result is:
4
Task author: Grzegorz Jakacki.