QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#909. 数点

Statistics

给一个排列 $p$,对每个 $i$,我们在平面上放置点 $(i,p_i)$。对于坐标上下限都在 $1\sim n$ 内的全体 $\left(\frac {n(n+1)}{2}\right)^2$ 种矩形,请你对每个矩形内部点数的 $k$ 次方求和。

形式化地,请你计算

$$ \sum_{1\le l\le r\le n} \sum_{1\le d\le u\le n} \left|\left\{ i\mid l\le i\le r \land d\le p_i\le u \right\}\right|^k $$

输入格式

第一行输入两个正整数 $n,k$。

第二行输入 $n$ 个正整数,即输入排列 $p$。

输出格式

输出答案,由于答案可能比较大,请输出它模 $998244353$ 后的结果。

样例数据

样例 1 输入

10 1
2 1 10 3 5 9 4 7 6 8

样例 1 输出

4948

样例 2 输入

10 2
2 1 10 3 5 9 4 7 6 8

样例 2 输出

16614

样例 3 输入

10 3
2 1 10 3 5 9 4 7 6 8

样例 3 输出

74224

子任务

对于 $100\%$ 的数据,保证 $1\le n\le 10^5; 1\le k\le 3$。

数据点编号 $n=$ $k=$
$1$ $50$ $3$
$2$ $300$ $1$
$3$ $2$
$4$ $3$
$5$ $3000$ $1$
$6$ $2$
$7$ $3$
$8$ $10^5$ $1$
$9$ $2$
$10$ $3$

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.