-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSequence_Game.cpp
More file actions
44 lines (42 loc) · 956 Bytes
/
Sequence_Game.cpp
File metadata and controls
44 lines (42 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int temp[2*n];
for(int i=0;i<2*n;i++) temp[i]=-1;
for(int i=0;i<n;i++){
temp[2*i]=arr[i];
}
vector<int> v;
n*=2;
n--;
for(int i=0;i<n;i++){
if(temp[i]!=-1) v.push_back(temp[i]);
else{
int prev=temp[i-1];
int next=temp[i+1];
if(prev>next){
v.push_back(next);
}
else{
continue;
}
}
}
cout<<v.size()<<endl;
for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
cout<<endl;
}
return 0;
}