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
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cerr << #x << " " << x << endl
#define int long long
#define st first
#define nd second

using namespace std;

const int N(1e6 + 113);
const int MAX(LLONG_MAX);

int n, to_pour, len;
pair <int, int> id, front_id;
bool flag;
int a, b, c, A, B, C, alfa, betaa, gammaa;
string s;
map <pair<int, int>, int> vis;
int res[N / 10];
queue < pair <int, int> > Q;

void gemacht() {
  if (!vis[id]) {
    Q.push(id);
    vis[id] = len + 1;
  }
}

int32_t main() {
  boost;
  cin >> A >> B >> C;
  cin >> a >> b >> c;

  for (int i = 0; i <= C; i++) {
    res[i] = INT_MAX;
  }

  Q.push({ a, b });
  vis[{a, b}] = 0;

  while (!Q.empty()) {
    alfa = Q.front().first;
    betaa = Q.front().second;
    Q.pop();
    gammaa = a + b + c - alfa - betaa;
    len = vis[{alfa, betaa}];
    res[alfa] = min(len, res[alfa]);
    res[betaa] = min(len, res[betaa]);
    res[gammaa] = min(len, res[gammaa]);


    to_pour = min(A - alfa, betaa);
    id = { alfa + to_pour, betaa - to_pour };
    gemacht();

    to_pour = min(alfa, B - betaa);
    id = { alfa - to_pour, betaa + to_pour };
    gemacht();

    to_pour = min(B - betaa, gammaa);
    id = { alfa, betaa + to_pour };
    gemacht();

    to_pour = min(C - gammaa, betaa);
    id = { alfa, betaa - to_pour };
    gemacht();

    to_pour = min(A - alfa, gammaa);
    id = { alfa + to_pour, betaa };
    gemacht();

    to_pour = min(alfa, C - gammaa);
    id = { alfa - to_pour, betaa };
    gemacht();
  }

  for (int i = 0; i <= C; i++) {
    if (res[i] == INT_MAX) {
      cout << "-1";
    } else {
      cout << res[i];
    }
    cout << " ";
  }
  cout << endl;
}