#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++)
while(x[i] && x[i - 1])
{
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
372 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
372 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
372 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
372 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 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 |
7 ms |
760 KB |
Output isn't correct |
9 |
Incorrect |
7 ms |
888 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
884 KB |
Output isn't correct |
11 |
Incorrect |
10 ms |
1272 KB |
Output isn't correct |