-
Notifications
You must be signed in to change notification settings - Fork 0
/
A. Ahahahahahahahaha.cpp
57 lines (57 loc) · 1.05 KB
/
A. Ahahahahahahahaha.cpp
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
//Solved
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int num;
cin>>num;
int onecount=0,zerocount=0;
while(num--)
{
int temp;
cin>>temp;
if(temp==1)
{
onecount++;
}
else
{
zerocount++;
}
}
if(zerocount>=onecount)
{
cout<<zerocount<<'\n';
for(int i=0;i<zerocount;i++)
{
cout<<"0";
if(i+1<zerocount)
{
cout<<" ";
}
}
cout<<'\n';
}
else
{
if(onecount%2==1)
{
onecount--;
}
cout<<onecount<<'\n';
for(int i=0;i<onecount;i++)
{
cout<<"0";
if(i+1<onecount)
{
cout<<" ";
}
}
cout<<'\n';
}
}
}