aboutsummaryrefslogtreecommitdiff
path: root/codeforces/strangeAddition/main.cpp
blob: 4e1e2033a21aad7253630f611fdb255f09595150 (plain)
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
#include <algorithm>
#include<bits/stdc++.h>

using namespace std;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  int n;
  cin >> n;
  int zeros = 0;
  vector<int> ind;
  vector<int> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
    int y = v[i];
    if(v[i] == 0) {
      zeros++;
      ind.push_back(i);
    }
    while(y >= 1) {
      int d = y % 10;
      y /= 10;
      if(d == 0) {
        zeros++;
        ind.push_back(i);
        break;
      }
    }
  }
  int diff = 1;
  zeros = zeros * 2;
  cout << min(zeros, n) << endl;
  vector<int> ans;
  for(int i = 0; i < n; i++) {
    if(count(ind.begin(), ind.end(), i)) {
      ans.push_back(v[i]);
    }
  }
  for(int i = 0; i < n; i++){
    if(!count(ind.begin(), ind.end(), i) && diff) {
      ans.push_back(v[i]);
      diff--;
    }
  }
  sort(ans.begin(), ans.end());
  for(auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}