#include <iostream>
#include <fstream>
using namespace std;
long long t,n,f[200010],q,ans[200010];
struct blocuri{long long poz,nrs,fmax;}a[200010];
ofstream out("fisier.txt");
ifstream in("ceva.txt");
int main()
{
in>>t;
while(t--)
{
ans[0]=0;
in>>n>>q;
for(long long i=2;i<=q+1;++i)
in>>f[i];
f[q+2]=n+1;
a[q+2].fmax=0;
a[q+2].poz=0;
a[q+2].nrs=0;
a[q+3].fmax=0;
a[q+3].poz=0;
a[q+3].nrs=0;
a[0].fmax=0;
a[0].poz=0;
a[0].nrs=0;
a[q+1].fmax=0;
a[q+1].poz=0;
a[q+1].nrs=0;
a[1].fmax=0;
a[1].poz=0;
a[1].nrs=0;
f[1]=0;
++q;
for(long long i=1;i<=q;++i)
{
a[i].poz=(f[i]+f[i+1])/2;
if(f[i+1]-f[i]<=3)
{
a[i].nrs=0;
a[i].fmax=f[i+1]-f[i]-1;
}
else
{
a[i].nrs=(f[i+1]-f[i]-4)/2;
if((f[i+1]-f[i])%2==0)
a[i].fmax=3;
else
a[i].fmax=4;
}
for(long long j=1;j<=a[i].nrs;++j)
ans[++ans[0]]=a[i].poz;
}
for(long long i=1;i<=q;++i)
{
if(a[i-1].fmax==0&&a[i].fmax!=0&&a[i+1].fmax==0)
ans[0]=-1;
else if(a[i-1].fmax==0&&a[i].fmax!=0)
{
if(a[i].fmax>2)
{
a[i].fmax-=2;
ans[++ans[0]]=a[i].poz;
}
}
else if(a[i].fmax!=0)
{
a[i].fmax-=a[i-1].fmax;
if(a[i].fmax<0)
{
out<<f[i+1]<<'\n';
ans[0]=-1;
}
else if(a[i+1].fmax==0)
{
if(a[i].fmax==2&&a[i-1].fmax!=0)
{
a[i].fmax-=2;
ans[++ans[0]]=a[i].poz;
}
else if(a[i].fmax!=0)
{
out<<f[i+1]<<'\n';
ans[0]=-1;
}
}
if(ans[0]>=0&&a[i].fmax>2/*&&(a[i].fmax!=3||a[i+1].fmax!=1)*/)
{
ans[++ans[0]]=a[i].poz;
a[i].fmax-=2;
}
if(a[i+1].fmax==1)
{
if(a[i].fmax==2)
{
if(a[i-1].fmax!=0)
{
a[i].fmax-=2;
ans[++ans[0]]=a[i].poz;
}
else
ans[0]=-1;
}
}
if(a[i].fmax==2&&a[i+1].fmax==2&&a[i+2].fmax>=2)
{
if(a[i-1].fmax!=0)
{
a[i].fmax-=2;
ans[++ans[0]]=a[i].poz;
}
}
if(ans[0]>=0)
for(long long j=0;j<a[i-1].fmax;++j)
ans[++ans[0]]=f[i];
}
if(ans[0]<0)
break;
}
cout<<ans[0]<<'\n';
if(ans[0]==-1)
out<<ans[0]<<'\n';
else
out<<1<<'\n';
for(long long i=1;i<=ans[0];++i)
cout<<ans[i]<<' ';
if(ans[0]>0)
cout<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
1 ms |
204 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
1 ms |
204 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
1 ms |
204 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
1 ms |
204 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |