# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
359776 | 2021-01-27T07:53:13 Z | ogibogi2004 | DEL13 (info1cup18_del13) | C++14 | 35 ms | 10156 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 d=v[i]-v[i-1]-1; for(int j1=0;j1<=2;j1++) { if(dp[i-1][j1]==0)continue; for(int j2=0;j2<=2;j2++) { if(j1+j2<=d&&(j1+j2)%2==d%2&&!(j1+j2==0&&d!=0)) { int l=v[i-1]+1; int r=v[i]-1; int mid=(l+r)/2; int cnt=(d-j1-j2)/2; vector<int>moves; for(int l=0;l<j1;l++)moves.push_back(v[i-1]); for(int k=0;k<cnt;k++)moves.push_back(mid); dp[i][j2]=1; prev[i][j2]={i-1,j1}; last[i][j2]=moves; } } } } 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 | 7544 KB | Output is correct |
2 | Correct | 8 ms | 7404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7544 KB | Output is correct |
2 | Correct | 8 ms | 7404 KB | Output is correct |
3 | Correct | 24 ms | 7404 KB | Output is correct |
4 | Correct | 24 ms | 7404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 7916 KB | Output is correct |
2 | Correct | 11 ms | 7836 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7544 KB | Output is correct |
2 | Correct | 8 ms | 7404 KB | Output is correct |
3 | Correct | 24 ms | 7404 KB | Output is correct |
4 | Correct | 24 ms | 7404 KB | Output is correct |
5 | Correct | 7 ms | 7404 KB | Output is correct |
6 | Correct | 7 ms | 7404 KB | Output is correct |
7 | Correct | 7 ms | 7404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7544 KB | Output is correct |
2 | Correct | 8 ms | 7404 KB | Output is correct |
3 | Correct | 24 ms | 7404 KB | Output is correct |
4 | Correct | 24 ms | 7404 KB | Output is correct |
5 | Correct | 7 ms | 7404 KB | Output is correct |
6 | Correct | 7 ms | 7404 KB | Output is correct |
7 | Correct | 7 ms | 7404 KB | Output is correct |
8 | Correct | 24 ms | 8072 KB | Output is correct |
9 | Correct | 27 ms | 8712 KB | Output is correct |
10 | Correct | 24 ms | 8600 KB | Output is correct |
11 | Correct | 35 ms | 10156 KB | Output is correct |