Sorting Program
Time limit2sMemory limit1024 MB
Count the input sequences of N integers in [1, M] that a given list of conditional swaps sorts into ascending order, modulo 998244353.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Bit manipulation, Simulation
- Solved
- No attempts yet
Problem
Students in the Computer Science and Engineering department at Seoul National University take the required course 'Logic Design' in their second year. The final project for this course is an FPGA (Field Programmable Gate Array) assignment, where students implement a program that meets a given specification. This year's project is a program that takes N integers, each between 1 and inclusive, and sorts them in ascending order.
The only operation students may use is the conditional_swap operation below. Every student's program is a sequence of conditional_swap operations.
conditional_swap(x, y): If the -th integer is greater than the -th integer, swap the positions of the two integers.
Minjun, the teaching assistant lead this semester, grades the students' programs. A student's score is the number of sequences that the program sorts into ascending order. Given a student's program, help Minjun compute the score the student will receive.
Input
The first line contains , , and separated by spaces. (; ; )
From the second line, lines each contain and separated by a space. ()
Output
Print the score the student receives, modulo 998244353. is prime.