|
|||
permutation-1
We have tasks labeled with numbers . For certain task pairs (), we know that one task () must be completed before we start the other (). Considering all valid orderings satisfying the given conditions in lexicographic order, find the -th ordering. For example, let N=4, M=3, and K=2,4: The given orders: 4 1 4 2 2 3 Then all possible orderings in lexicographic order: 4 1 2 3 4 2 1 3 4 2 3 1 We can see that 4 2 1 3 is the second, and also clear that there is no fourth valid ordering. Input specificationThe first line contains , the number of test cases. Then test cases follow. Description of a test case: First line: three numbers . Next lines: numbers . Each pair appears at most once in the list. Output specificationT lines with the… Constraints
Sample input 1
Sample output 1
|
|||
| University of Debrecen; Faculty of Informatics; v. 09/30/2024 |