시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 2 | 1 | 1 | 50.000% |
A permutation p of length n is an array {p1, p2, . . . , pn} that contains each integer from 1 to n once. Jack devised five criteria that are supposed to show how close a permutation p is to the identity permutation {1, 2, . . . , n}:
Jill wants to prove him that these criteria can vary independently (in some sense). She need to show that two permutations p and q of equal length can give any combination of:
Help Jill prove her thesis in a constructive way. For a given set of relations between these criteria, find two permutations p and q of the same length that satisfy these relations.
The first line of the input file contains two integer numbers n and l — the number of relations and permutations length (1 ≤ n ≤ 243; 1 ≤ l ≤ 1000).
Each of the following n lines contains one set criteria that is defined by the five characters. Each character is either ‘<’, ‘=’, or ‘>’. These characters denote desired relations between a(p) and a(q), . . ., e(p) and e(q) (in this order)
For each set of criteria given in the input file output either “Exists” if there exists a pair of permutations p and q of length l satisfying this set of criteria, and “Not exists” otherwise.
In the former case following two lines must contain permutation p and q (in this order).
3 4 <==<> <<<<< =====
Exists 1 4 2 3 2 3 4 1 Not exists Exists 1 2 3 4 1 2 3 4
In the first pair of permutations in sample output:
a(p)= 2 < 3=a(q); b(p)= 1 = 1=b(q); c(p)= 3 = 3=c(q); d(p)= 2 < 3=d(q); e(p)= 1 > 0=e(q).