QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#905. 三元环枚举

Statistics

给定一个包含 $N$ 个顶点和 $M$ 条边的简单无向图。 第 $i$ 条边为 $\lbrace u_i, v_i \rbrace$。 每个顶点都有一个整数值,第 $i$ 个顶点的值为 $x_i$。

由三条边 $\lbrace a, b \rbrace, \lbrace a, c \rbrace, \lbrace b, c \rbrace$ 连接的三个顶点 $a, b, c (a < b < c)$ 被称为三角形。 求所有三角形的 $x_a x_b x_c$ 之和,并将结果对 $998\,244\,353$ 取模。

数据范围

  • $1 \le N \le 10^5$
  • $1 \le M \le 10^5$
  • $0 \le x_i < 998\,244\,353$
  • $0 \le u_i < N$
  • $0 \le v_i < N$
  • $u_i \neq v_i$
  • $\lbrace u_i, v_i \rbrace \neq \lbrace u_j, v_j \rbrace \ (i \neq j)$

输入格式

  • $N$ $M$
  • $x_0$ $x_1$ $\ldots$ $x_{N-1}$
  • $u_0$ $v_0$
  • $u_1$ $v_1$
  • $\vdots$
  • $u_{M-1}$ $v_{M-1}$

输出格式

  • $A$

样例

输入 1

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

输出 1

36

说明 1

$0, 2, 3$ 和 $1, 2, 3$ 是三角形。 输出 $36$,即 $1 \cdot 3 \cdot 4 + 2 \cdot 3 \cdot 4 \bmod 998\,244\,353$ 的结果。

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.