Universal Cup Judging System

Universal Cup

Time Limit: 4.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Mô tả

Bạn được cho một số nguyên dương $N$, một số nguyên tố $P$, và một dãy số nguyên dương $A = (A_1, A_2, \dots, A_N)$ có độ dài $N$, trong đó mỗi phần tử đều nhỏ hơn $P$. Đặt $S = \{1, 2, \dots, N\}$.

Hãy tìm số lượng dãy tập hợp $T$ có độ dài ít nhất là $1$ thỏa mãn tất cả các điều kiện sau, và in ra kết quả theo modulo $P$.

  • Mọi phần tử của $T$ đều là một tập con khác rỗng của $S$.
  • Với mỗi $i = 1, 2, \dots, N$, điều kiện sau được thỏa mãn:
    • Trong số các phần tử của $T$, có đúng $A_i$ phần tử chứa $i$.

Dữ liệu vào

Dữ liệu vào được cho theo định dạng sau:

N P
A_1 A_2 ... A_N
  • $1 \le N \le 2 \times 10^5$
  • $113 \le P \le 500009$
  • $P$ là một số nguyên tố
  • $1 \le A_i < P$ ($1 \le i \le N$)
  • Tất cả các giá trị đầu vào đều là số nguyên

Dữ liệu ra

In ra đáp án.

Ví dụ

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

Ghi chú

Ở ví dụ thứ nhất, các dãy $T$ có thể là $(\{1, 2\}, \{2\})$, $(\{2\}, \{1, 2\})$, $(\{1\}, \{2\}, \{2\})$, $(\{2\}, \{1\}, \{2\})$, $(\{2\}, \{2\}, \{1\})$, tổng cộng có $5$ dãy.

Ở ví dụ thứ hai, đừng quên tìm số lượng dãy $T$ hợp lệ theo modulo $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.