# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
486133 |
2021-11-10T15:26:04 Z |
leaked |
DEL13 (info1cup18_del13) |
C++14 |
|
44 ms |
6272 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;
}
set<int>st;
for(int i=1;i<=n;i++) st.insert(i);
for(auto &z : ans){
auto it=st.lower_bound(z);
if(it==st.begin() || next(it)==st.end()) assert(false);
int j=*prev(it),k=*next(it);
st.erase(j);st.erase(k);
}
vec<int> byla;
for(auto &z : st) byla.pb(z);
assert(byla==a);
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 |
2 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 |
2 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
9 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
12 ms |
332 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
728 KB |
Output is correct |
2 |
Correct |
4 ms |
1392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
9 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
12 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
9 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
12 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
8 |
Incorrect |
13 ms |
1132 KB |
Output isn't correct |
9 |
Incorrect |
25 ms |
3876 KB |
Output isn't correct |
10 |
Incorrect |
17 ms |
3156 KB |
Output isn't correct |
11 |
Incorrect |
44 ms |
6272 KB |
Output isn't correct |