Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100
Statistics

Bạn được cho một dãy độ dài $N$, $A = (A_1, A_2, \dots, A_N)$. Đối với dãy $A$ này, hãy thực hiện thao tác sau theo thứ tự với $i = 1, 2, \dots, N - 1$:

  • Hoặc đổi chỗ $A_i$ và $A_{i+1}$, hoặc không làm gì cả.

Hãy tìm số lượng dãy phân biệt có thể thu được sau khi thực hiện các thao tác này, theo modulo $998244353$.

Dữ liệu vào

Dữ liệu vào được cho theo định dạng sau:

$$\begin{aligned} &N \\ &A_1 \ A_2 \ \dots \ A_N \end{aligned}$$

  • Tất cả dữ liệu vào đều là số nguyên.
  • $1 \le N \le 10^6$
  • $1 \le A_i \le N$

Kết quả

In ra câu trả lời trên một dòng duy nhất.

Ví dụ

Dữ liệu vào 1

5
1 2 1 2 3

Kết quả 1

10

Dữ liệu vào 2

9
3 1 6 2 2 7 7 6 6

Kết quả 2

104

Giải thích

Trong ví dụ thứ nhất, có $10$ dãy có thể thu được sau khi thực hiện các thao tác. Các dãy đó là:

  • $(1, 2, 1, 2, 3)$,
  • $(1, 2, 1, 3, 2)$,
  • $(1, 2, 2, 1, 3)$,
  • $(1, 2, 2, 3, 1)$,
  • $(1, 1, 2, 2, 3)$,
  • $(1, 1, 2, 3, 2)$,
  • $(2, 1, 1, 2, 3)$,
  • $(2, 1, 1, 3, 2)$,
  • $(2, 1, 2, 1, 3)$,
  • $(2, 1, 2, 3, 1)$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1409EditorialOpen题解jianglyView

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.