| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 1024 MB | 54 | 36 | 29 | 69.048% |
To commemorate the end of a memorable era, the city is holding a Last Celebration. As a grand finale, a group of $N$ artists has been commissioned to create a final, collaborative mural on a massive city wall. The wall has a length of $D$ and is divided into $D$ sections, numbered from 1ドル$ to $D$. Before they begin, the entire wall is primed with a base color, represented as color 0ドル$.
Each artist $i$ is assigned a specific task: to paint the sections from $l_i$ to $r_i$ with their designated color $c_i$. As the artists work, some sections might be painted over multiple times. The final color of any section is determined by the last artist to paint it.
The quality of the final artwork is determined by its diversity. A block is defined as a maximal contiguous segment of the wall painted in a single color. The diversity of the wall is the total number of blocks.
The $N$ artists will complete their tasks in a random order. Each of the $N!$ possible permutations is equally likely. Your goal is to calculate the expected value of the wall's diversity after all artists are finished.
The first line contains two integers, $D$ and $N$ — the length of the wall and the number of artists.
The following $N$ lines each contain three integers, $l_i,ドル $r_i,ドル and $c_i$ — the range and color for the $i$-th artist.
Output the expected value of the wall's diversity. Since the expectation can be rational, output it modulo 998ドル,244円,353円$. Formally, if the expectation equals $s/t$ in lowest terms, print $s\times t^{-1}\pmod{998,244円,353円},ドル where $t^{-1}$ is the modular inverse of $t$ modulo 998ドル,244円,353円$.
5 2 1 4 1 2 3 2
3
6 3 2 3 1 4 5 1 1 6 2
332748120
1000000000 9 1 2 1 11 22 1 111 222 1 1111 2222 1 11111 22222 1 111111 222222 1 1111111 2222222 1 11111111 22222222 1 111111111 222222222 1
18
4 10 1 1 1 1 2 2 1 3 3 1 4 4 2 2 5 2 3 6 2 4 7 3 3 8 3 4 9 4 4 10
356515843
University > KAIST > KAIST ICPC Mock Competition > 2025 KAIST 15th ICPC Mock Competition L번
University > MIT > The MIT Programming Contest > 2025-26 > MIT Team Contest 2 L번