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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#include <bits/stdc++.h>

using namespace std;

#define MAX_N 100007

using Dziad = pair <int, pair <int, int>>;

class Ayaya {
public:

  Dziad d;
  int ile_bylo = 0;

  Ayaya(Dziad dz, int x) {
    d = dz;
    ile_bylo = x;
  }
};

int mA, mB, mC, a, b, c;
int minval, maxval, h_values;
int prob[MAX_N];
queue <Ayaya> q;
set <Dziad> s;

void proceedThis(Ayaya x) {
  int av = x.d.first;
  int bv = x.d.second.first;
  int cv = x.d.second.second;
  if (prob[av] == -1) {
    prob[av] = x.ile_bylo;
    h_values--;
  }
  if (prob[bv] == -1) {
    prob[bv] = x.ile_bylo;
    h_values--;
  }
  if (prob[cv] == -1) {
    prob[cv] = x.ile_bylo;
    h_values--;
  }
  int nav = av;
  int nbv = bv;
  int ncv = cv;

  nbv += nav;
  nav = 0;
  if (nbv > mB) {
    int temp = nbv - mB;
    nbv = mB;
    nav = temp;
  }
  //cout << "1: " << nav << " " << nbv << " " << " " << ncv << "\n";
  Dziad to_push = {nav, {nbv, ncv}};
  if (s.find(to_push) == s.end()) {
    s.insert(to_push);
    Ayaya qtp(to_push, x.ile_bylo + 1);
    q.push(qtp);
  }

  nav = av;
  nbv = bv;
  ncv = cv;

  nav += nbv;
  nbv = 0;
  if (nav > mA) {
    int temp = nav - mA;
    nav = mA;
    nbv = temp;
  }
  //cout << "2: " << nav << " " << nbv << " " << " " << ncv << "\n";
  Dziad to_push2 = {nav, {nbv, ncv}};
  if (s.find(to_push2) == s.end()) {
    s.insert(to_push2);
    Ayaya qtp2(to_push2, x.ile_bylo + 1);
    q.push(qtp2);
  }

  // a c

  nav = av;
  nbv = bv;
  ncv = cv;

  ncv += nav;
  nav = 0;
  if (ncv > mC) {
    int temp = ncv - mC;
    ncv = mC;
    nav = temp;
  }
  //cout << "3: " << nav << " " << nbv << " " << " " << ncv << "\n";
  Dziad to_push3 = {nav, {nbv, ncv}};
  if (s.find(to_push3) == s.end()) {
    s.insert(to_push3);
    Ayaya qtp3(to_push3, x.ile_bylo + 1);
    q.push(qtp3);
  }

  nav = av;
  nbv = bv;
  ncv = cv;

  nav += ncv;
  ncv = 0;
  if (nav > mA) {
    int temp = nav - mA;
    nav = mA;
    ncv = temp;
  }
  //cout << "4: " << nav << " " << nbv << " " << " " << ncv << "\n";
  Dziad to_push4 = {nav, {nbv, ncv}};
  if (s.find(to_push4) == s.end()) {
    s.insert(to_push4);
    Ayaya qtp4(to_push4, x.ile_bylo + 1);
    q.push(qtp4);
  }

  // b c

  nav = av;
  nbv = bv;
  ncv = cv;

  ncv += nbv;
  nbv = 0;
  if (ncv > mC) {
    int temp = ncv - mC;
    ncv = mC;
    nbv = temp;
  }

  //cout << "5: " << nav << " " << nbv << " " << " " << ncv << "\n";
  Dziad to_push5 = {nav, {nbv, ncv}};
  if (s.find(to_push5) == s.end()) {
    s.insert(to_push5);
    Ayaya qtp5(to_push5, x.ile_bylo + 1);
    q.push(qtp5);
  }

  nav = av;
  nbv = bv;
  ncv = cv;

  nbv += ncv;
  ncv = 0;
  if (nbv > mB) {
    int temp = nbv - mB;
    //cout << "temp" << temp << " ";
    nbv = mB;
    ncv = temp;
  }
  //cout << "6: " << nav << " " << nbv << " " << " " << ncv << "\n";
  Dziad to_push6 = {nav, {nbv, ncv}};
  if (s.find(to_push6) == s.end()) {
    s.insert(to_push6);
    Ayaya qtp6(to_push6, x.ile_bylo + 1);
    q.push(qtp6);
  }

}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> mA >> mB >> mC;
  cin >> a >> b >> c;
  int temp = mB + mC;
  int ora = a + b + c;
  minval = max(0, ora - temp);
  maxval = min(mC, a + b + c);
  //cout << minval << " " << maxval;
  h_values = maxval - minval + 1;

  for (int i = 0; i <= mC; i++) {
    prob[i] = -1;
  }

  Dziad pocz = {a, {b, c}};
  Ayaya qpocz(pocz, 0);
  q.push(qpocz);
  s.insert(pocz);
  while (h_values > 0 && !q.empty()) {
    Ayaya curX = q.front();
    //cout << curX.d.first << " " << curX.d.second.first << " " << curX.d.second.second << "\n";
    q.pop();
    proceedThis(curX);
  }
  for (int i = 0; i <= mC; i++) {
    cout << prob[i] << " ";
  }
}