QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 512 MB Puntuación total: 100

#909. Decimal Point

Estadísticas

Given a permutation $p$, for each $i$, we place a point $(i, p_i)$ on a plane. For all $\left(\frac{n(n+1)}{2}\right)^2$ possible rectangles with coordinates within the range $1 \sim n$, calculate the sum of the $k$-th power of the number of points inside each rectangle.

Formally, calculate:

$$ \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 $$

Input

The first line contains two positive integers $n$ and $k$.

The second line contains $n$ positive integers, representing the permutation $p$.

Output

Output the answer. Since the answer may be large, output it modulo $998244353$.

Examples

Input 1

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

Output 1

4948

Input 2

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

Output 2

16614

Input 3

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

Output 3

74224

Subtasks

For $100\%$ of the data, $1\le n\le 10^5$ and $1\le k\le 3$.

Data Point ID $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: 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.