QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#4220. 連接點

统计

圓周上有 $3n$ 個不同的點。每個點都被塗上 $n$ 種顏色中的其中一種,使得每一種顏色恰好出現三次。

你想要畫出 $n$ 條互不相交的弧,且每條弧的兩端點皆位於給定的點上。

對於這些弧,弧的兩個端點必須具有相同的顏色,且弧上不應包含任何其他相同顏色的點。

注意,你畫的是弧,而不是弦。

請計算符合條件的畫法數量,並對 $998\,244\,353$ 取模。

輸入格式

第一行包含一個整數 $n$ ($1 \le n \le 200\,000$):顏色的數量。

下一行包含 $3n$ 個整數 $c_1, c_2, \dots, c_{3n}$ ($1 \le c_i \le n$):依順時針順序排列的圓周上各點的顏色。

保證每一種顏色恰好出現三次。

輸出格式

輸出一個整數:符合條件的畫法數量,對 $998\,244\,353$ 取模。

範例

輸入格式 1

3
1 1 1 2 2 2 3 3 3

輸出格式 1

8

輸入格式 2

2
1 1 2 2 1 2

輸出格式 2

3

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.