#include <bits/stdc++.h>
#define NM 100002
using namespace std;
int t;
int n, q;
int p[NM];
int x[NM];
vector <int> op;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while(t--)
{
cin >> n >> q;
for(int i = 1; i <= q; i++)
cin >> p[i];
op.clear();
p[q + 1] = n + 1;
for(int i = 0; i <= q; i++)
x[i] = p[i + 1] - p[i] - 1;
for(int i = 0; i <= q; i++)
{
int mid = p[i] + (x[i] + 1) / 2;
while(x[i] > 2)
{
op.push_back(mid);
x[i] -= 2;
}
}
for(int i = 1; i <= q; i++)
if(x[i - 1] == x[i])
{
while(x[i])
{
x[i]--;
x[i - 1]--;
op.push_back(p[i]);
}
}
bool ok = 1;
for(int i = 0; i <= q; i++)
if(x[i] > 0)
{
ok = 0;
break;
}
if(ok)
{
cout << op.size() << "\n";
for(auto i : op)
cout << i << " ";
cout << "\n";
}
else
cout << "-1\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
6 ms |
1016 KB |
Output isn't correct |
9 |
Incorrect |
7 ms |
1144 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
1148 KB |
Output isn't correct |
11 |
Incorrect |
7 ms |
1272 KB |
Output isn't correct |