{"problem":{"name":"The Greatest Two","description":{"content":"You are given integers $N$ and $K$, and a permutation $P=(P_1,P_2,\\cdots,P_N)$ of $(1,2,\\cdots,N)$. You can perform the following operation any number of times, possibly zero. *   Choose an integer $","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":5000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"wtf22_day2_b"},"statements":[{"statement_type":"Markdown","content":"You are given integers $N$ and $K$, and a permutation $P=(P_1,P_2,\\cdots,P_N)$ of $(1,2,\\cdots,N)$.\nYou can perform the following operation any number of times, possibly zero.\n\n*   Choose an integer $i$ ($1 \\leq i \\leq N-K+1$). Swap the values of the two greatest elements among $P_i,P_{i+1},\\cdots,P_{i+K-1}$.\n\nFind the number, modulo $998244353$, of permutations that $P$ can be after your operations.\n\n## Constraints\n\n*   $2 \\leq K \\leq N \\leq 250000$\n*   $(P_1,P_2,\\cdots,P_N)$ is a permutation of $(1,2,\\cdots,N)$.\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $K$\n$P_1$ $P_2$ $\\cdots$ $P_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"wtf22_day2_b","tags":[],"sample_group":[["3 3\n2 3 1","2\n\nIn this case, the operation can only be performed with $i=1$.\nAfter one operation, the two greatest elements among $P_1,P_2,P_3$, which are $P_2=3$ and $P_1=2$, have their values swapped, and you have $P=(3,2,1)$. After one more operation, you have $P=(2,3,1)$.\nThus, there are two permutations, $P=(2,3,1),(3,2,1)$, that $P$ can be after your operations."],["3 2\n1 3 2","6"],["10 5\n1 2 3 4 5 6 7 8 9 10","144"],["20 5\n8 13 6 11 20 3 12 18 17 4 10 1 7 16 19 5 2 15 14 9","1451520"]],"created_at":"2026-03-03 11:01:14"}}