Submission #520984

#TimeUsernameProblemLanguageResultExecution timeMemory
520984lucriDEL13 (info1cup18_del13)C++17
0 / 100
9 ms464 KiB
#include <iostream> using namespace std; int t,n,f[210],b[210],a[210],q,ans[210]; bool ok[210]; int main() { cin>>t; while(t--) { ans[0]=0; cin>>n>>q; for(int i=1;i<=q;++i) cin>>f[i]; int j=1; for(int i=1;i<=n;++i) { if(f[j]==i) { ++j; ok[i]=true; } else ok[i]=false; b[i]=i-1; a[i]=i+1; } a[0]=1; bool x=true; while(x) { x=false; for(int i=1;i<=n;++i) { if(ok[b[i]]==false&&ok[a[i]]==false&&b[i]!=0&&a[i]!=n+1) { x=true; ans[++ans[0]]=i; a[b[b[i]]]=i; b[a[a[i]]]=i; a[i]=a[a[i]]; b[i]=b[b[i]]; } } } for(int i=a[0];i<=n;i=a[i]) { if(ok[i]==false) { ans[0]=-1; break; } } cout<<ans[0]<<'\n'; for(int i=1;i<=ans[0];++i) cout<<ans[i]<<' '; if(ans[0]>0) cout<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...