CF1227F1.Wrong Answer on test 233 (Easy Version)

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Your program fails again. This time it gets "Wrong answer on test 233"

.

This is the easier version of the problem. In this version 1≤n≤20001 \le n \le 2000. You can hack this problem only if you solve and lock both problems.

The problem is about a test containing nn one-choice-questions. Each of the questions contains kk options, and only one of them is correct. The answer to the ii-th question is hih_{i}, and if your answer of the question ii is hih_{i}, you earn 11 point, otherwise, you earn 00 points for this question. The values h1,h2,…,hnh_1, h_2, \dots, h_n are known to you in this problem.

However, you have a mistake in your program. It moves the answer clockwise! Consider all the nn answers are written in a circle. Due to the mistake in your program, they are shifted by one cyclically.

Formally, the mistake moves the answer for the question ii to the question i mod n+1i \bmod n + 1. So it moves the answer for the question 11 to question 22, the answer for the question 22 to the question 33, ..., the answer for the question nn to the question 11.

We call all the nn answers together an answer suit. There are knk^n possible answer suits in total.

You're wondering, how many answer suits satisfy the following condition: after moving clockwise by 11, the total number of points of the new answer suit is strictly larger than the number of points of the old one. You need to find the answer modulo 998 244 353998\,244\,353.

For example, if n=5n = 5, and your answer suit is a=[1,2,3,4,5]a=[1,2,3,4,5], it will submitted as a′=[5,1,2,3,4]a'=[5,1,2,3,4] because of a mistake. If the correct answer suit is h=[5,2,2,3,4]h=[5,2,2,3,4], the answer suit aa earns 11 point and the answer suite a′a' earns 44 points. Since 4>14 \gt 1, the answer suit a=[1,2,3,4,5]a=[1,2,3,4,5] should be counted.

你的程序再次出错。这次报错为“测试 233 答案错误”。

本题是简化版本,在该版本中 1≤n≤20001 \le n \le 2000。仅当你解决并锁定本题及其对应困难版本后,才可对该题进行 Hack。

本题涉及一份包含 nn 道单选题的试卷。每道题有 kk 个选项,其中仅有一个正确。第 ii 道题的正确答案为 hih_{i};若你对第 ii 道题的回答恰好为 hih_{i},则得 11 分,否则得 00 分。本题中,所有 h1,h2,…,hnh_1, h_2, \dots, h_n 的值均已知。

然而,你的程序存在一个错误:它会将所有答案顺时针移动一位!具体而言,假设全部 nn 个答案按环形排列,由于该错误,每个答案均被循环右移一位。

形式化地,该错误将第 ii 道题的答案移至第 i mod n+1i \bmod n + 1 道题处。即:第 11 道题的答案移至第 22 道题,第 22 道题的答案移至第 33 道题,……,第 nn 道题的答案移至第 11 道题。

我们将全部 nn 个答案合称为一个答题方案。总共有 knk^n 种可能的答题方案。

你现在想知道:有多少种答题方案满足如下条件——将其顺时针移动一位后,新答题方案的总得分严格大于原答题方案的总得分?你需要输出答案对 998 244 353998\,244\,353 取模的结果。

例如,若 n=5n = 5,你的答题方案为 a=[1,2,3,4,5]a=[1,2,3,4,5],则因该错误,实际提交的方案为 a′=[5,1,2,3,4]a'=[5,1,2,3,4]。若标准答案为 h=[5,2,2,3,4]h=[5,2,2,3,4],则原方案 aa 得 11 分,而新方案 a′a' 得 44 分。由于 4>14 > 1,因此答题方案 a=[1,2,3,4,5]a=[1,2,3,4,5] 应被计入。

输入格式

The first line contains two integers nn, kk (1≤n≤20001 \le n \le 2000, 1≤k≤1091 \le k \le 10^9) — the number of questions and the number of possible answers to each question.

The following line contains nn integers h1,h2,…,hnh_1, h_2, \dots, h_n, (1≤hi≤k)1 \le h_{i} \le k) — answers to the questions.

第一行包含两个整数 nn、kk(1≤n≤20001 \le n \le 2000,1≤k≤1091 \le k \le 10^9)—— 分别表示问题的数量以及每个问题的可能答案数量。

接下来的一行包含 nn 个整数 h1,h2,…,hnh_1, h_2, \dots, h_n(1≤hi≤k1 \le h_{i} \le k)—— 表示各问题的答案。

输出格式

Output one integer: the number of answers suits satisfying the given condition, modulo 998 244 353998\,244\,353.

输出一个整数:满足给定条件的答案个数,对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    3 3
    1 3 1

    输出#1

    9
  • 输入#2

    5 5
    1 1 4 2 2

    输出#2

    1000

说明/提示

For the first example, valid answer suits are [2,1,1],[2,1,2],[2,1,3],[3,1,1],[3,1,2],[3,1,3],[3,2,1],[3,2,2],[3,2,3][2,1,1], [2,1,2], [2,1,3], [3,1,1], [3,1,2], [3,1,3], [3,2,1], [3,2,2], [3,2,3].

对于第一个样例,合法的答案组合有 [2,1,1],[2,1,2],[2,1,3],[3,1,1],[3,1,2],[3,1,3],[3,2,1],[3,2,2],[3,2,3][2,1,1], [2,1,2], [2,1,3], [3,1,1], [3,1,2], [3,1,3], [3,2,1], [3,2,2], [3,2,3]。

输入解题思路,AI测评打分。不知道怎么写?

首页