# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
359754 | 2021-01-27T07:37:59 Z | ogibogi2004 | DEL13 (info1cup18_del13) | C++14 | 26 ms | 8812 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN=1e5+6; bool dp[MAXN][3]; vector<int>last[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; } } 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; } } } } if(dp[v.size()-1][0]) { cout<<"0\n"; } else { cout<<"-1\n"; } } int main() { int t; cin>>t; while(t--)solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
3 | Correct | 20 ms | 7404 KB | Output is partially correct |
4 | Correct | 18 ms | 7404 KB | Output is partially correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 7788 KB | Output is partially correct |
2 | Correct | 10 ms | 8140 KB | Output is partially correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
3 | Correct | 20 ms | 7404 KB | Output is partially correct |
4 | Correct | 18 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 | 8 ms | 7532 KB | Output is partially correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7404 KB | Output is partially correct |
2 | Correct | 7 ms | 7404 KB | Output is partially correct |
3 | Correct | 20 ms | 7404 KB | Output is partially correct |
4 | Correct | 18 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 | 8 ms | 7532 KB | Output is partially correct |
8 | Correct | 26 ms | 8140 KB | Output is partially correct |
9 | Correct | 26 ms | 8512 KB | Output is partially correct |
10 | Correct | 23 ms | 8172 KB | Output is partially correct |
11 | Correct | 24 ms | 8812 KB | Output is partially correct |