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
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
#define ssize(x) int(x.size())
template<class A, class B> auto& operator<<(ostream &o, pair<A, B> p) {
    return o << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &o, T x) -> decltype(x.end(), o) {
    o << '{'; int i = 0; for(auto e : x) o << (", ")+2*!i++ << e; return o << '}';
}
ostream& operator<<(ostream &o, string &s) {
    return o << s.data();   
}
#ifdef DEBUG
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#else
#define debug(...) {}
#endif

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int a, b, c;
    int x, y, z;
    cin >> a >> b >> c;
    cin >> x >> y >> z;
    vector<int> ans(c + 1, -1);
    map<pair<int, pair<int, int> >, int> vis;
    queue<pair<int, pair<int, int> > > q;
    vis[{x, {y, z}}] = 1;
    q.push({x, {y, z}});
    
    auto refill = [&](int p, int R, int r) -> pair<int, int> {
        if (p + r <= R)
            return {0, p + r};
        else
            return {p - (R - r), R};
    };

    auto check = [&](int p, int r, int s, int T) {
        if (vis[{p, {r, s}}] == 0) {
            vis[{p, {r, s}}] = T + 1;
            q.push({p, {r, s}});
        }
    };

    while (!q.empty()) {
        auto [d, p] = q.front();
        auto [e, f] = p;
        q.pop();
        int tm = vis[{d, p}];

        auto [u, v] = refill(d, b, e);
        check(u, v, f, tm);
        auto [u1, v1] = refill(d, c, f);
        check(u1, e, v1, tm);
        auto [u2, v2] = refill(e, c, f);
        check(d, u2, v2, tm);
        auto [u3, v3] = refill(e, a, d);
        check(v3, u3, f, tm);
        auto [u4, v4] = refill(f, a, d);
        check(v4, e, u4, tm);
        auto [u5, v5] = refill(f, b, e);
        check(d, v5, u5, tm);
    }

    auto minimize = [&](int v, int res) {
        res--;
        if (ans[v] == -1 || ans[v] > res)
            ans[v] = res;
    };

    for (auto [p, res] : vis) {
        auto [d, p1] = p;
        auto [e, f] = p1;
        minimize(d, res);
        minimize(e, res);
        minimize(f, res);
    }

    REP(i, c + 1)
        cout << ans[i] << ' ';
    cout << '\n';

    return 0;
}