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
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define se second
#define N (int)1e5 + 2

int n, A, B, C, aa, bb, cc, odp[N], lic;
map<pair<pair<int, int>, int>, int> mp;

void obl(int a, int b, int c, int ile)
{
    /* lic++;
    if (lic >= 15)
        return;
*/
    if (mp.count({{a, b}, c}) > 0 && mp[{{a, b}, c}] <= ile)
        return;
    //  cout << a << " " << b << " " << c << " " << mp[{{a, b}, c}] << " " << ile << endl;
    mp[{{a, b}, c}] = ile;
    if (odp[a] == 0 || odp[a] > ile)
        odp[a] = ile;
    if (odp[b] == 0 || odp[b] > ile)
        odp[b] = ile;
    if (odp[c] == 0 || odp[c] > ile)
        odp[c] = ile;

    int oile = min(a, B - b);
    if (oile)
        obl(a - oile, b + oile, c, ile + 1);
    oile = min(b, A - a);
    if (oile)
        obl(a + oile, b - oile, c, ile + 1);

    oile = min(a, C - c);
    if (oile)
        obl(a - oile, b, c + oile, ile + 1);
    oile = min(c, A - a);
    if (oile)
        obl(a + oile, b, c - oile, ile + 1);

    oile = min(b, C - c);
    if (oile)
        obl(a, b - oile, c + oile, ile + 1);
    oile = min(c, B - b);
    if (oile)
        obl(a, b + oile, c - oile, ile + 1);
}
int main()
{
    scanf("%d%d%d%d%d%d", &A, &B, &C, &aa, &bb, &cc);
    obl(aa, bb, cc, 1);
    for (int i = 0; i <= C; ++i)
    {
        printf("%d ", odp[i] - 1);
    }
}