#Y. XHXMMMl31UFZWg#-@_/
XHXMMMl31UFZWg#-@_/
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Statement
Monocarp wants to throw a party. He has friends, and he wants to have at least of them at his party.
The -th friend's best friend is . All are distinct, and for every , .
Monocarp can send invitations to friends. The -th friend comes to the party if both the -th friend and the -th friend receive an invitation (note that the -th friend doesn't have to actually come to the party). Each invitation is sent to exactly one of the friends.
For example, if , and Monocarp sends invitations to the friends , then the friends will come to the party. The friend won't come since his best friend didn't receive an invitation; the friend won't come since he didn't receive an invitation.
Calculate the minimum number of invitations Monocarp has to send so that at least friends come to the party.
Format
Input
The first line contains one integer ( ) — the number of test cases.
Each test case consists of two lines:
- the first line contains one integer ( ) — the number of friends;
- the second line contains integers ( ; ; all are distinct).
Output
Print one integer — the minimum number of invitations Monocarp has to send.
Sample
3
5
3 1 2 5 4
4
2 3 4 1
2
2 1
2
3
2
ShanghaiTech ACM 炸鱼杯
- 状态
- 已结束
- 规则
- OI
- 题目
- 46
- 开始于
- 2024-12-10 23:00
- 结束于
- 2024-12-15 13:00
- 持续时间
- 110 小时
- 主持人
- 参赛人数
- 112