QOJ.ac

QOJ

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

#4881. Bài toán khó

Statistiques

Bạn được cho một mảng số nguyên $a_1, \dots, a_n$. Một đoạn con có độ dài chẵn $a_i, \dots, a_{i+2m-1}$ được gọi là tốt nếu $|\max(a_i, \dots, a_{i+m-1}) - \max(a_{i+m}, \dots, a_{i+2m-1})| \le k$.

Định nghĩa dãy số nguyên $f$ như sau:

  • $f_1 = 3240$
  • $f_2 = 3081$
  • $f_3 = 2841$
  • $f_4 = 343$
  • $f_i = f_{i-1} \cdot 223 + f_{i-2} \cdot 229 + f_{i-3} \cdot f_{i-4} \cdot 239 + 17$ với $i > 4$

Hãy tính tổng $(a_{i+m-1} + 10) \cdot f_m$ trên tất cả các đoạn con tốt. Vì số này có thể rất lớn, hãy in ra kết quả theo modulo $998\,244\,353$.

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên $t$ ($1 \le t \le 10^4$) — số lượng bộ dữ liệu. Tiếp theo là mô tả các bộ dữ liệu.

Dòng đầu tiên của mỗi bộ dữ liệu chứa hai số nguyên $n, k$ ($1 \le n \le 5 \cdot 10^5, 0 \le k \le \min(n, 10)$).

Dòng tiếp theo chứa $n$ số nguyên $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$).

Đảm bảo rằng tổng của $n$ trên tất cả các bộ dữ liệu không vượt quá $5 \cdot 10^5$.

Dữ liệu ra

Với mỗi bộ dữ liệu, in ra một số nguyên duy nhất — đáp án của bài toán.

Ví dụ

Dữ liệu vào 1

3
6 0
3 1 3 1 3 1
8 4
5 8 4 6 5 7 8 5
7 3
2 1 3 2 2 1 3

Dữ liệu ra 1

144768
745933
448953

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#626Editorial Open集训队作业 解题报告 by 陈奕帆Qingyu2026-01-02 23:20:04 Download

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.