# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96496 | 2019-02-09T18:02:49 Z | KLPP | DEL13 (info1cup18_del13) | C++14 | 500 ms | 1656 KB |
#include<bits/stdc++.h> using namespace std; int n; bool done; bool possible[300000]; int par[1000000]; int mve[1000000]; void DFS(int mask){ if(possible[mask])return; possible[mask]=true; int arr[n]; for(int i=0;i<n;i++){ arr[i]=((mask&(1<<i))>0); } int prev[n]; int next[n]; prev[0]=-1; for(int i=1;i<n;i++){ if(arr[i-1]==1)prev[i]=prev[i-1]; else prev[i]=i-1; } next[n-1]=n; for(int i=n-2;i>-1;i--){ if(arr[i+1]==1)next[i]=next[i+1]; else next[i]=i+1; } /*for(int i=0;i<n;i++){ cout<<prev[i]<<" "<<next[i]<<endl; }*/ for(int i=0;i<n;i++){ if(arr[i]==0 && prev[i]!=-1 && next[i]!=n){ int less=(1<<prev[i])+(1<<next[i]); if(!possible[mask+less]){ par[mask+less]=mask; mve[mask+less]=i; DFS(mask+less); } } } } int main(){ int t; cin>>t; done=false; while(t--){ cin>>n; if(!done){ for(int i=0;i<(1<<n);i++)possible[i]=false; DFS(0); /*for(int mask=0;mask<(1<<n);mask++){ for(int i=0;i<n;i++)cout<<((mask&(1<<i))>0); cout<<" "<<possible[mask]<<endl; }*/ } int l; cin>>l; int MSK=(1<<n)-1; for(int i=0;i<l;i++){ int x; cin>>x; x--; MSK-=(1<<x); } if(possible[MSK]){ vector<int> seq; while(MSK!=0){ seq.push_back(mve[MSK]); MSK=par[MSK]; } reverse(seq.begin(),seq.end()); cout<<seq.size()<<endl; for(int j=0;j<seq.size();j++)cout<<seq[j]+1<<" "; cout<<endl; } else cout<<-1<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Execution timed out | 1083 ms | 1144 KB | Time limit exceeded |
4 | Execution timed out | 1076 ms | 1656 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 1016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Runtime error | 3 ms | 1016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Execution timed out | 1083 ms | 1144 KB | Time limit exceeded |
4 | Execution timed out | 1076 ms | 1656 KB | Time limit exceeded |
5 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 3 ms | 1016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Execution timed out | 1083 ms | 1144 KB | Time limit exceeded |
4 | Execution timed out | 1076 ms | 1656 KB | Time limit exceeded |
5 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 3 ms | 1016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 3 ms | 1148 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 3 ms | 1016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 4 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 3 ms | 760 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |