CF1343D.Constant Palindrome Sum
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a consisting of n integers (it is guaranteed that n is even, i.e. divisible by 2 ). All ai does not exceed some integer k .
Your task is to replace the minimum number of elements (replacement is the following operation: choose some index i from 1 to n and replace ai with some integer in range [1;k] ) to satisfy the following conditions:
- after all replacements, all ai are positive integers not greater than k ;
- for all i from 1 to 2n the following equation is true: ai+an−i+1=x , where x should be the same for all 2n pairs of elements.
You have to answer t independent test cases.
输入格式
The first line of the input contains one integer t ( 1≤t≤104 ) — the number of test cases. Then t test cases follow.
The first line of the test case contains two integers n and k ( 2≤n≤2⋅105,1≤k≤2⋅105 ) — the length of a and the maximum possible value of some ai correspondingly. It is guratanteed that n is even (i.e. divisible by 2 ). The second line of the test case contains n integers a1,a2,…,an ( 1≤ai≤k ), where ai is the i -th element of a .
It is guaranteed that the sum of n (as well as the sum of k ) over all test cases does not exceed 2⋅105 ( ∑n≤2⋅105 , ∑k≤2⋅105 ).
输出格式
For each test case, print the answer — the minimum number of elements you have to replace in a to satisfy the conditions from the problem statement.
输入输出样例
输入#1
4 4 2 1 2 1 2 4 3 1 2 2 1 8 7 6 1 1 7 6 3 4 6 6 6 5 2 6 1 3 4
输出#1
0 1 4 2