Logo
(追記) (追記ここまで)

24944번 - Misspelling 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3.5 초 1024 MB58302850.000%

문제

Some time ago, President K had a string $S$ of length $N$ consisting of lower case characters. But, he forgot it. He had a dictionary which contains misspellings of several kinds, and he once took a look at the dictionary to check the misspellings of the string $S$. Now, he remembers that the following is true for the string $S$.

  • Let $T_i$ (1ドル ≤ i ≤ N$) be the string obtained from $S$ by deleting the $i$-th character and removing the gap. For each $j$ (1ドル ≤ j ≤ M$), the relation $T_{A_j} ≤ T_{B_j}$ holds.

Here, $T_{A_j} ≤ T_{B_j}$ means either $T_{A_j}$ is equal to $T_{B_j},ドル or $T_{A_j}$ is smaller than $T_{B_j}$ in the lexicographic order (alphabetical order).

Write a program which, given information on the string $S$ remembered by President K, calculates the number of strings $S$ modulo 1ドル,000円,000円,007円$ which do not contradict given information.

입력

Read the following data from the standard input. Given values are all integers.

$\begin{align*} & N ,円 M \\ & A_1 ,円 B_1 \\ & A_2 ,円 B_2 \\ & \vdots \\ & A_M,円 B_M \end{align*}$

출력

Write one line to the standard output. The output should contain the number of strings $S$ modulo 1ドル,000円,000円,007円$ which do not contradict given information.

제한

  • 2ドル ≤ N ≤ 500,000円$.
  • 1ドル ≤ M ≤ 500,000円$.
  • 1ドル ≤ A_j ≤ N$ (1ドル ≤ j ≤ M$).
  • 1ドル ≤ B_j ≤ N$ (1ドル ≤ j ≤ M$).
  • $A_j \ne B_j$ (1ドル ≤ j ≤ M$).
  • $(A_j , B_j) \ne (A_k, B_k)$ (1ドル ≤ j < k ≤ M$).

서브태스크

번호배점제한
18

$N ≤ 10$.

220

$N ≤ 200$.

329

$M = N - 1$. Moreover, there exists a permutation $P$ of $(1, 2, \dots , N)$ of length $N$ satisfying $A_j = P_j$ and $B_j = P_{j+1}$ (1ドル ≤ j ≤ M$).

432

$N ≤ 20,000円$.

511

No additional constraints.

예제 입력 1

3 2
1 3
3 2

예제 출력 1

5876

For example, if the string $S$ is bab, we have $T_1 = $ab, $T_2 = $bb, $T_3 = $ba. The relations $T_1 ≤ T_3$ and $T_3 ≤ T_2$ hold. This string does not contradict given information. In total, there are 5876ドル$ strings $S$ which do not contradict given information. Therefore, output 5876ドル$.

On the other hand, for example, if the strings $S$ is aab, we have $T_1 = $ab, $T_2 = $ab, $T_3 = $aa. The relation $T_1 ≤ T_3$ does not hold. Therefore, this string contradicts given information.

This sample input satisfies the constraints of all the subtasks.

예제 입력 2

5 6
1 2
1 5
2 4
5 4
5 3
4 3

예제 출력 2

656981

This sample input satisfies the constraints of Subtasks 1, 2, 4, 5.

예제 입력 3

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

예제 출력 3

206289833

The number of strings $S$ which do not contradict given information is 824ドル,206円,295円,601円$. Therefore, output 206ドル,289円,833円,ドル which is the remainder of 824ドル,206円,295円,601円$ when divided by 1ドル,000円,000円,007円$.

This sample input satisfies the constraints of Subtasks 1, 2, 4, 5.

예제 입력 4

7 6
1 3
3 4
4 6
6 5
5 7
7 2

예제 출력 4

7125651

This sample input satisfies the constraints of all the subtasks.

예제 입력 5

5 4
2 4
4 3
3 5
5 1

예제 출력 5

61451

This sample input satisfies the constraints of all the subtasks.

힌트

출처

Camp > JOI Spring Training Camp > JOI 2021/2022 Spring Training Camp 1-3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /