# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549970 | 2022-04-17T02:08:24 Z | fcmalkcin | DEL13 (info1cup18_del13) | C++17 | 10 ms | 4312 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" #define pb push_back #define F(i,a,b) for(ll i=a;i<=b;i++) const ll maxn=3e5+10 ; const ll base=1e9; const ll mod= 1e9+7 ; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); /// have medal in APIO /// goal 2/8 ll dp[maxn][3]; ll a[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("t.inp","r")) { freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } ll t; cin>> t; while (t--) { ll n, k; cin>> n>> k; vector<ll> vt; ll pre=0; for (int i=1; i<=k; i++) { cin>> a[i]; vt.pb(a[i]-pre-1); pre=a[i]; } vt.pb(n-pre); if (vt[0]%2==1) dp[0][1]=1; else if (vt[0]==0) dp[0][0]=1; else dp[0][2]=1; for (int i=1; i<=k; i++) { for (int t=0; t<=2; t++) { if (dp[i-1][t]&&vt[i]>=t) { if (t==0) { if (vt[i]%2==0) { if (vt[i]) dp[i][2]=t+1; else dp[i][0]=t+1; } else dp[i][1]=t+1; } else if (t==1) { ll nxt=(vt[i]-t)%2; dp[i][nxt]=t+1; } else { if (vt[i]%2==1) { dp[i][1]=t+1; } else { if (vt[i]==2) { dp[i][0]=t+1; } else { dp[i][0]=t+1; dp[i][2]=t+1; } } } } } } if (dp[k][0]) { vector<ll> vt1; vt1.pb(0); ll nw=0; for (int i=k; i>=1; i--) { nw=dp[i][nw]-1; vt1.pb(nw); } reverse(vt1.begin(),vt1.end()); for (auto to:vt1) { // cout <<to<<" chk1"<<endl; } ll st=0; vector<ll> res; for (int i=0; i<vt1.size(); i++) { ll pre=0; if (i) pre=vt1[i-1]; if (pre==0) { ll sl=(vt[i]-vt1[i])/2; ll nw=st+2; while (sl--) { res.pb(nw); nw+=2; } } else if (pre==1) { for (int h=1; h<=pre; h++) res.pb(st); ll sl=(vt[i]-pre-1)/2; ll nw=st+pre+2; while (sl--) { res.pb(nw); nw+=2; } } else { if (vt1[i]>=1) { res.pb(st); res.pb(st); ll sl=(vt[i]-1)/2-1; ll nw=st+4; while (sl--) { res.pb(nw); nw+=2; } } else { ll sl=(vt[i])/2-1; ll nw=st+2; while (sl--) { res.pb(nw); nw+=2; } res.pb(st); res.pb(st); } } st+=vt[i]+1; } cout <<res.size()<<endl; for (auto to:res) cout <<to<<" "; cout <<endl; } else { cout <<-1<<endl; } for (int i=0; i<=n; i++) { for (int t=0; t<=2; t++) dp[i][t]=0; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 440 KB | Output isn't correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 440 KB | Output isn't correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Incorrect | 4 ms | 340 KB | Output isn't correct |
4 | Incorrect | 4 ms | 412 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 656 KB | Output is partially correct |
2 | Correct | 2 ms | 2260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 440 KB | Output isn't correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Incorrect | 4 ms | 340 KB | Output isn't correct |
4 | Incorrect | 4 ms | 412 KB | Output isn't correct |
5 | Incorrect | 1 ms | 340 KB | Output isn't correct |
6 | Incorrect | 1 ms | 340 KB | Output isn't correct |
7 | Incorrect | 1 ms | 360 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 440 KB | Output isn't correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Incorrect | 4 ms | 340 KB | Output isn't correct |
4 | Incorrect | 4 ms | 412 KB | Output isn't correct |
5 | Incorrect | 1 ms | 340 KB | Output isn't correct |
6 | Incorrect | 1 ms | 340 KB | Output isn't correct |
7 | Incorrect | 1 ms | 360 KB | Output isn't correct |
8 | Incorrect | 5 ms | 2900 KB | Output isn't correct |
9 | Incorrect | 7 ms | 3548 KB | Output isn't correct |
10 | Incorrect | 9 ms | 3376 KB | Output isn't correct |
11 | Incorrect | 10 ms | 4312 KB | Output isn't correct |