-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path669a.cpp
More file actions
57 lines (51 loc) · 999 Bytes
/
669a.cpp
File metadata and controls
57 lines (51 loc) · 999 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
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define f(i,n) for(int i=0;i<n;i++)
#define forall(i,a,b) for(int i=a;i<b;i++)
#define INF 2147483647
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int32_t main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int z=0,o=0;
f(i,n){
int a;
cin>>a;
if(a==1)o++;
else z++;
}
if(n/2%2){
if(z>=o){
cout<<n/2<<endl;
f(i,n/2)cout<<"0 ";
}
else{
cout<<n/2+1<<endl;
f(i,n/2+1)cout<<"1 ";
}
}
else{
if(z>=o){
cout<<n/2<<endl;
f(i,n/2)cout<<"0 ";
}
else{
cout<<n/2<<endl;
f(i,n/2)cout<<"1 ";
}
}
cout<<endl;
}
return 0;
}