# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
486131 |
2021-11-10T15:19:57 Z |
leaked |
DEL13 (info1cup18_del13) |
C++14 |
|
20 ms |
6536 KB |
#include <bits/stdc++.h>
#define f first
#define s second
#define vec vector
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m_p make_pair
#define pw(x) (1LL<<x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fast_rmi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<class T> bool umin(T &a, const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a, const T &b){return (a<b?a=b,1:0);}
typedef pair<int,int> pii;
signed main(){
fast_rmi;
int t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
vec<vec<int>>dp(k+2,vec<int>(3,0));
vec<vec<int>> p(k+2,vec<int>(3,0));
vec<int>a(k);
vec<pii>me;
for(auto &z : a) cin>>z;
int prv=0;
for(auto &z : a) me.pb({prv+1,z-1}),prv=z;
me.pb({prv+1,n});
vec<int>ans;
int ok=1;
for(auto &z : me){
int cnt=z.s-z.f+1;
vec<int> og;
for(int j=z.f;j<=z.s;j++) og.pb(j);
while(cnt>=3){
cnt-=2;
ans.pb(og[sz(og)-2]);
og.pop_back();
swap(og[sz(og)-1],og[sz(og)-2]);
og.pop_back();
}
z.f=z.s-cnt+1;
// cout<<"KEK" <<z.f<<' '<<z.s<<' '<<cnt<<endl;
}
for(int i=1;i<sz(me);i++){
while(1){
int x=me[i-1].s-me[i-1].f+1;
int y=me[i].s-me[i].f+1;
if(x && y){
me[i-1].f++;me[i].f++;
ans.pb(a[i-1]);
continue;
}
break;
}
// ok&=((me[i].s-me[i].f+1)==0);
}
for(auto &z : me) ok&=((z.s-z.f+1)==0);
if(!ok){
cout<<-1<<'\n';
continue;
}
cout<<sz(ans)<<'\n';
for(auto &z : ans) cout<<z<<' ';
cout<<'\n';
}
return 0;
}
/*
2 3
7 4 3
5 2 5
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
412 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
332 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
652 KB |
Output is correct |
2 |
Correct |
5 ms |
1452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
412 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
412 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
8 |
Incorrect |
15 ms |
1384 KB |
Output isn't correct |
9 |
Incorrect |
15 ms |
3280 KB |
Output isn't correct |
10 |
Incorrect |
15 ms |
3540 KB |
Output isn't correct |
11 |
Incorrect |
20 ms |
6536 KB |
Output isn't correct |