Universal Cup Judging System

Universal Cup

시간 제한: 4.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

문제 설명

양의 정수 $N$, 소수 $P$, 그리고 각 원소가 $P$보다 작은 길이 $N$의 양의 정수 수열 $A = (A_1, A_2, \dots, A_N)$이 주어집니다. $S = \{1, 2, \dots, N\}$이라 합시다.

다음 조건을 모두 만족하는 길이가 $1$ 이상인 집합들의 수열 $T$의 개수를 구하고, 그 결과를 $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.