QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#5524. 帮我把它发表了

Statistiques

$n$ 个节点的完全图的 Gallai 着色是指对其边进行的一种染色,满足以下条件:

  • 不存在三条边颜色各不相同的三角形。

节点 $v$ 的颜色度数 $d(v)$ 定义为与 $v$ 相连的边中出现的不同颜色的数量。如果存在一种 $n$ 个节点的完全图的 Gallai 着色,使得对于所有 $1 \le i \le n$ 都有 $d(i) = a_i$,则称序列 $(a_1, a_2, \dots, a_n)$ 为有效的度数序列。

给定 $a_i$ 的部分值,其中一些值为 $-1$。求将 $a$ 中等于 $-1$ 的元素替换为正整数,使得序列成为有效度数序列的方法数。由于该数字可能很大,请输出其对 $998244353$ 取模的结果。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 100$)。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n - 1$ 或 $a_i = -1$)。如果 $a_i \neq -1$,则给出其值。

输出格式

输出一个整数,表示将 $a$ 中等于 $-1$ 的元素替换后,得到有效度数序列的方法数,对 $998244353$ 取模。

样例

样例输入 1

2
1 -1

样例输出 1

1

样例输入 2

3
-1 -1 -1

样例输出 2

4

样例输入 3

6
5 -1 -1 -1 -1 -1

样例输出 3

120

说明

在第一个样例中,唯一的有效度数序列是 $(1, 1)$。

在第二个样例中,有效的度数序列为 $(1, 1, 1), (1, 2, 2), (2, 1, 2), (2, 2, 1)$,其中第一个对应所有边颜色相同的情况,后三个对应其中两条边颜色相同的情况。

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.