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
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, n) for (int i = 0; i < int(n); ++i)
#define FO(i, a, b) for (int i = (a); i < int(b); ++i)
#define OF(i, a, b) for (int i = (b)-1; i >= int(a); --i)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((b) < (a) ? (a) : (b))

#define REMIN(a, b) ((a) = min(a, b))
#define REMAX(a, b) ((a) = max(a, b))

#define ALL(c) (c).begin(), (c).end()

#define SQR(x) ((x) * (x))

#define PRINT(x) cerr << #x << " == " << x << endl;

//

int cap[3];
int a, b, c;

using R = array<int, 3>;

R pour(const R &r, int fr, int to) {
  int amt = min(r[fr], cap[to] - r[to]);
  R res = r;
  res[fr] -= amt;
  res[to] += amt;
  return res;
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> cap[0] >> cap[1] >> cap[2] >> a >> b >> c;

  map<R, int> s;
  deque<R> todo;

  s[{a, b, c}] = 0;
  todo.push_back({a, b, c});

  while (!todo.empty()) {
    auto r = todo.front();
    todo.pop_front();

    // cerr << "process " << r[0] << " " << r[1] << " " << r[2] << endl;

    int val = s[r] + 1;

    FOR(i, 3) FOR(j, 3) if (i != j) {
      auto rr = pour(r, i, j);
      if (s.find(rr) != s.end())
        continue;

      s[rr] = val;
      todo.push_back(rr);
    }
  }

  vector<int> res(cap[2] + 1, INT_MAX);

  for (auto &[k, v] : s) {
    FOR(i, 3) { REMIN(res[k[i]], v); }
  }

  FOR(i, cap[2] + 1) cout << (res[i] == INT_MAX ? -1 : res[i]) << " ";
  cout << endl;

  return 0;
}