#include <bits/stdc++.h>
#define NM 100002
using namespace std;
int t;
int n, k;
int p[NM], d[NM];
vector <int> op;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> t;
while(t--)
{
cin >> n >> k;
op.clear();
p[0] = 0;
p[k + 1] = n + 1;
for(int i = 1; i <= k; i++)
cin >> p[i];
k++;
for(int i = 1; i <= k; i++)
{
d[i] = p[i] - p[i - 1] - 1;
if(d[i] == 0)
d[i] = 0;
else if(d[i] % 2 == 1)
{
for(int j = 1; j <= d[i] / 2; j++)
op.push_back(p[i - 1] + d[i] / 2 + 1);
d[i] = 1;
}
else
{
for(int j = 1; j <= d[i] / 2 - 1; j++)
op.push_back(p[i - 1] + d[i] / 2 + 1);
d[i] = 2;
}
}
bool ok = 1;
for(int i = 1; i <= k; i++)
{
int mi = min(d[i], d[i + 1]);
for(int j = 1; j <= mi; j++)
op.push_back(p[i]);
d[i] -= mi;
d[i + 1] -= mi;
if(d[i] > 0)
{
ok = 0;
break;
}
}
if(ok == 0)
cout << "-1\n";
else
{
cout << op.size() << "\n";
for(auto i : op)
cout << i << " ";
cout << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
756 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
824 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1096 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1384 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
756 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
824 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
1384 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
1384 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
1384 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
756 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
824 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
1384 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
1384 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
1384 KB |
Output isn't correct |
8 |
Incorrect |
13 ms |
1580 KB |
Output isn't correct |
9 |
Incorrect |
9 ms |
2056 KB |
Output isn't correct |
10 |
Incorrect |
8 ms |
2356 KB |
Output isn't correct |
11 |
Incorrect |
12 ms |
3008 KB |
Output isn't correct |