Loading repovive.com/contests/21/problems/B
You are given a permutation of the integers from to .
A permutation of the integers from to is called good if, for every ,
Find the number of good permutations.
The input consists of two lines:
The two good permutations are and . For each of them, the maximums of adjacent pairs are .
The first required maximum forces the first two elements of to be and in some order. The second required maximum then forces the third element to be , making the next adjacent maximum at least instead of . Therefore, no good permutation exists.