QOJ.ac

QOJ

時間限制: 10.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#14510. 合唱隊形

统计

J. 合唱隊形

作為一名 CPer,小 M 在訓練的時候,曾不幸讀錯一道題目,並遺憾爆零。

時光流逝,如今再來回首,小 M 發現這個錯誤的題意背後原來也深藏著一個有趣的故事...

或許這會是對你的挑戰吧。

回到曾經。你的面前有 $n$ 名學生依次站成了一排,依次標號為 $0, 1, 2, \dots, n-1$。你打算教他們一些歌曲。歌曲一共有 $m$ 首,依次標號為 $0, 1, 2, \dots, m-1$。一開始這些學生一首歌都不會唱。

你希望這些學生能夠學會由此達成的合唱。定義一個從 $x$ 號學生開始的合唱,是由 $x$ 號學生唱 $0$ 號歌曲,由 $x+1$ 號學生唱 $1$ 號歌曲,由 $x+i$ 號學生唱 $i$ 號歌曲 ($\forall i \in [0, m)$)。如果這些學生都會唱了自己的歌曲,那麼這個合唱方案就被稱為可達成的。

學生標號是不循環的,因此如果上述定義中出現了不合法的標號,就直接認為這個合唱方案不存在。

因為你分身乏術,你每一單位時間打算教其中一個人一首歌曲。

簡單來說,你先確定了一個長度為 $S$ 的課程列表 $\Phi = \{(r_1, s_1), (r_2, s_2), \dots, (r_S, s_S)\}$,滿足各項 $0 \le r \le n-1$,$0 \le s \le m-1$,且這個列表是可重的。每一單位時間內,你會在課程列表的 $S$ 種方案中等機率獨立均勻隨機一個 $(r, s)$,然後執行這一課程,也即教 $r$ 號人學會唱第 $s$ 首歌曲。因為你的記性不好,你也有可能重複講授相同的課程。

對於所有滿足 $1 \le p \le n$ 的正整數 $p$ 求出,期望多少單位時間後,開始存在至少 $p$ 種不同的合唱方案,使得這些合唱方案是可達成的。

輸入格式

第一行三個整數 $n, m, S$ ($1 \le m \le n \le 80, 1 \le S \le 15000$)。

接下來 $S$ 行,每行兩個整數 $r, s$ ($0 \le r \le n-1, 0 \le s \le m-1$),表示課程列表中的一組課程,滿足其為教 $r$ 號學生 $s$ 號歌曲。

輸出格式

一行 $n$ 個整數,表示 $p = 1, 2, \dots, n$ 時依次對應的答案。如果存在請輸出對 $998244353$ 取模的結果,否則請在對應位置直接輸出 $-1$。

形式化地,令 $M = 998244353$,可以證明,精確答案可以用不可約分數 $\frac{p}{q}$ 表示,其中 $p$ 和 $q$ 是整數且 $q \not\equiv 0 \pmod M$。你需要輸出的是 $p \cdot q^{-1} \pmod M$,也就是輸出滿足 $0 \le x < M$ 且 $qx \equiv p \pmod M$ 的整數 $x$。可以證明,符合條件的 $x$ 是唯一的。

範例

範例輸入 1

2 1 2
0 0
1 0

範例輸出 1

1 3

範例輸入 2

5 2 4
0 0
1 1
2 0
3 1

範例輸出 2

665496239 332748126 -1 -1 -1

範例輸入 3

10 1 13
0 0
1 0
2 0
3 0
3 0
3 0
3 0
4 0
5 0
6 0
6 0
6 0
7 0

範例輸出 3

1 177465665 198136383 907170767 930038200 516623876 417879798 928849837 -1 -1

範例輸入 4

5 3 17
0 0
1 0
2 0
2 0
2 0
4 0
0 1
1 1
1 1
2 1
3 1
1 2
2 2
2 2
3 2
4 2
4 2

範例輸出 4

325476536 76195241 263824532 -1 -1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#508Editorial Open总之是出题人题解myee2026-01-02 21:33:21View PDF

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.