# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
359760 | 2021-01-27T07:42:27 Z | ogibogi2004 | DEL13 (info1cup18_del13) | C++14 | 35 ms | 10160 KB |
#include<bits/stdc++.h> using namespace std; #define prev sdsdfsdsf const int MAXN=1e5+6; bool dp[MAXN][3]; vector<int>last[MAXN][3]; pair<int,int>prev[MAXN][3]; void solve() { int n,q; cin>>n>>q; vector<int>v; v.push_back(0); for(int i=0;i<q;i++) { int p; cin>>p; v.push_back(p); } v.push_back(n+1); for(int i=0;i<=v.size();i++) { for(int j=0;j<3;j++) { dp[i][j]=0; last[i][j].clear(); } } dp[0][0]=1; for(int i=1;i<v.size();i++) { int t=v[i]-v[i-1]-1; vector<int>moves; int mid=(v[i]+v[i-1])/2; while(t>2) { moves.push_back(mid); t-=2; } for(int j=0;j<=t;j++) { if(dp[i-1][j]) { vector<int>l=moves; for(int k=0;k<j;k++) { l.push_back(v[i-1]); } dp[i][t-j]=1; last[i][t-j]=l; prev[i][t-j]={i-1,j}; } } if(moves.size()>0) { moves.pop_back(); t+=2; for(int j=t-2;j<=2;j++) { if(dp[i-1][j]) { vector<int>l=moves; for(int k=0;k<j;k++) { l.push_back(v[i-1]); } dp[i][t-j]=1; last[i][t-j]=l; prev[i][t-j]={i-1,j}; } } } } if(dp[v.size()-1][0]) { //cout<<"0\n"; vector<int>out; int x=v.size()-1,y=0; while(!(x==0&&y==0)) { for(auto xd:last[x][y])out.push_back(xd); tie(x,y)=prev[x][y]; } reverse(out.begin(),out.end()); cout<<out.size()<<endl; for(auto xd:out)cout<<xd<<" "; cout<<endl; } else { cout<<"-1\n"; } } int main() { int t; cin>>t; while(t--)solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
3 | Correct | 24 ms | 7532 KB | Output is partially correct |
4 | Correct | 25 ms | 7404 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 7916 KB | Output is partially correct |
2 | Correct | 11 ms | 8140 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
3 | Correct | 24 ms | 7532 KB | Output is partially correct |
4 | Correct | 25 ms | 7404 KB | Output is partially correct |
5 | Correct | 6 ms | 7404 KB | Output is partially correct |
6 | Correct | 6 ms | 7404 KB | Output is partially correct |
7 | Correct | 7 ms | 7404 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
3 | Correct | 24 ms | 7532 KB | Output is partially correct |
4 | Correct | 25 ms | 7404 KB | Output is partially correct |
5 | Correct | 6 ms | 7404 KB | Output is partially correct |
6 | Correct | 6 ms | 7404 KB | Output is partially correct |
7 | Correct | 7 ms | 7404 KB | Output is partially correct |
8 | Correct | 25 ms | 8076 KB | Output is partially correct |
9 | Correct | 27 ms | 8620 KB | Output is partially correct |
10 | Correct | 25 ms | 8684 KB | Output is partially correct |
11 | Correct | 35 ms | 10160 KB | Output is partially correct |