Universal Cup Judging System

Universal Cup

実行時間制限: 4.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

คำอธิบาย

กำหนดจำนวนเต็มบวก $N$ จำนวนเฉพาะ $P$ และลำดับของจำนวนเต็มบวก $A = (A_1, A_2, \dots, A_N)$ ที่มีความยาว $N$ ซึ่งแต่ละสมาชิกมีค่าน้อยกว่า $P$ ให้ $S = \{1, 2, \dots, N\}$

จงหาจำนวนของลำดับของเซต $T$ ที่มีความยาวอย่างน้อย $1$ ซึ่งสอดคล้องกับเงื่อนไขต่อไปนี้ทั้งหมด แล้วแสดงผลลัพธ์มอดุโล $P$

  • ทุกสมาชิกของ $T$ เป็นสับเซตที่ไม่เป็นเซตว่างของ $S$
  • สำหรับแต่ละ $i = 1, 2, \dots, N$ เป็นไปตามเงื่อนไขต่อไปนี้:
    • ในบรรดาสมาชิกของ $T$ มีอยู่ $A_i$ ตัวพอดีที่มี $i$ เป็นสมาชิก

ข้อมูลนำเข้า

ข้อมูลนำเข้ากำหนดให้ในรูปแบบต่อไปนี้:

N P
A_1 A_2 ... A_N
  • $1 \le N \le 2 \times 10^5$
  • $113 \le P \le 500009$
  • $P$ เป็นจำนวนเฉพาะ
  • $1 \le A_i < P$ ($1 \le i \le N$)
  • ค่าในข้อมูลนำเข้าทั้งหมดเป็นจำนวนเต็ม

ข้อมูลส่งออก

พิมพ์คำตอบ

ตัวอย่าง

2 113
1 2
5
4 8191
7 6 3 8
4477

หมายเหตุ

สำหรับตัวอย่างแรก ลำดับ $T$ ที่เป็นไปได้คือ $(\{1, 2\}, \{2\})$, $(\{2\}, \{1, 2\})$, $(\{1\}, \{2\}, \{2\})$, $(\{2\}, \{1\}, \{2\})$, $(\{2\}, \{2\}, \{1\})$ รวมทั้งหมด $5$ ลำดับ

สำหรับตัวอย่างที่สอง อย่าลืมหาจำนวนของลำดับ $T$ ที่ถูกต้องมอดุโล $P$

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1492EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.