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

#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define vb vector<bool>
#define vvb vector<vb>
#define vl vector<ll>
#define endl '\n'
#define turbo ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define f first
#define s second

using namespace std;

map<vi, int> se;
int t[3];

vi p(vi v, int a, int b)
{ 
    int a1 = min(v[a]+v[b], t[a]);
    int b1 = v[b] - (a1-v[a]);
    v[a] = a1;
    v[b] = b1;
    return v;
}

queue<pair<vi, int>> q;

void go()
{
    while(q.size())
    {
        vi v = q.front().f;
        int ile = q.front().s;
        q.pop();

        for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                if(i != j)
                {
                    vi pom = p(v, i, j);
                    if(se.find(pom) == se.end())
                    {
                        se[pom] = ile+1;
                        q.push({pom, ile+1});
                    }
                    else if(se[pom] > ile+1)
                    {
                        se[pom] = ile+1;
                        q.push({pom, ile+1});
                    }
                }
    }
}

int main()
{
    turbo
    cin >> t[0] >> t[1] >> t[2];
    int a, b, c; cin >> a >> b >> c;
    vi pom = {a, b, c};
    se[pom] = 0;
    q.push({pom, 0});
    go();
    map<int, int> ma;
    for(auto itv : se)
        for(auto it : itv.f)
        {
            if(ma.find(it) == ma.end()) ma[it] = itv.s;
            else ma[it] = min(ma[it], itv.s);
        }
    for(int i = 0; i <= t[2]; i++)
        cout << (ma.find(i) != ma.end() ? ma[i] : -1) << ' ';
    cout << endl;
}