#include <stdio.h>
#include <string.h>
#define N 100000
int main() {
int t;
scanf("%d", &t);
while (t--) {
static int ii[N], pp[N + 1];
int n, m, k, h, i, j, l, r;
scanf("%d%d", &n, &m);
for (h = 0; h < m; h++)
scanf("%d", &ii[h]), ii[h]--;
memset(pp, -1, (n + 1) * sizeof *pp), pp[0] = -2;
for (h = 0; h < m; h++) {
l = h == 0 ? 0 : ii[h - 1] + 1, r = h + 1 == m ? n : ii[h + 1];
for (i = l; i < ii[h]; i++)
if (pp[i] != -1) {
for (j = ii[h] + 2; j <= r; j++)
if (j % 2 == (h + 1) % 2)
pp[j] = i;
break;
}
if (pp[ii[h]] != -1)
pp[ii[h] + 1] = ii[h];
}
if (pp[n] == -1) {
printf("-1\n");
continue;
}
printf("%d\n", (n - m) / 2);
for (h = m - 1, r = n; h >= 0; h--) {
l = pp[r], i = ii[h];
if (i - l <= r - i) {
k = (r + l) / 2 - i;
while (k--)
printf("%d ", i + 3);
k = i - l;
while (k--)
printf("%d ", i + 1);
} else {
k = i - (r + l) / 2;
while (k--)
printf("%d ", i - 1);
k = r - i;
while (k--)
printf("%d ", i + 1);
}
r = l;
}
printf("\n");
}
return 0;
}
Compilation message
del13.c: In function 'main':
del13.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | scanf("%d", &t);
| ^~~~~~~~~~~~~~~
del13.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
del13.c:16:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d", &ii[h]), ii[h]--;
| ^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
348 KB |
Integer -1 violates the range [1, 17] |
4 |
Incorrect |
3 ms |
772 KB |
Integer -1 violates the range [1, 18] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
348 KB |
Integer -1 violates the range [1, 17] |
4 |
Incorrect |
3 ms |
772 KB |
Integer -1 violates the range [1, 18] |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
348 KB |
Integer -1 violates the range [1, 100] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
348 KB |
Integer -1 violates the range [1, 17] |
4 |
Incorrect |
3 ms |
772 KB |
Integer -1 violates the range [1, 18] |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
348 KB |
Integer -1 violates the range [1, 100] |
8 |
Incorrect |
8 ms |
1116 KB |
More than N moves |
9 |
Incorrect |
6 ms |
1116 KB |
Output isn't correct |
10 |
Incorrect |
6 ms |
1152 KB |
Output isn't correct |
11 |
Incorrect |
9 ms |
1464 KB |
Output isn't correct |