F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Count Set

Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1550    Accepted Submission(s): 480


Problem Description
Given a permutation $p$ of $\{1,2,\cdots, n\}$ and a non-negative integer $k$. Please calculate the number of subsets $T$ of $\{1,2,3,4,...n\}$ satisfying $|T|=k$ and $|P(T)\cap T|=0$.

Where $P(T)$ means $P(T)=\lbrace y|y=p_x,x\in T\rbrace$.
 

Input
Each test contains multiple test cases. The first line contains the number of test cases $(1 \le T \le 15)$. Description of the test cases follows.

The first line contains two separated integers $n$, $k$.

The second line contains $n$ integers $P_1, P_2, \cdots, P_n\,(1\le P_i \le n)$, denoting the given permutation.

$1\leq n\leq 5 \times 10^5, 0\leq k\leq n$.

For all test cases,$\sum n\leq 5\times 10^6$
 

Output
For each test case:

Print one integer in a line, denoting the answer number modulo $998\ 244\ 353$.
 

Sample Input
3 5 1 5 3 2 1 4 5 2 2 5 1 3 4 10 3 10 9 3 8 6 4 5 7 2 1
 

Sample Output
5 5 40
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 08:15:03, Gzip enabled