QOJ.ac

QOJ

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

#909. 数点

統計

给一个排列 $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$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.