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
89
90
91
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second

using namespace std;

int A, B, C;

map<pair<pair<int, int>, int>, int> mp;

void solve(int a, int b, int c){
	queue<pair<pair<int, int>, int>> q;
	q.push({{a, b}, c});
	while(q.size()){
		pair<pair<int, int>, int> tmp = q.front();
		q.pop();
		a = tmp.f.f;
		b = tmp.f.s;
		c = tmp.s;
		int v = mp[{{a, b}, c}];
		int na, nb, nc;	
		na = min(A, a+b);
		nb = max(0, b-(A-a));
		nc = c;
		if(mp[{{na, nb}, nc}]==0){
			mp[{{na, nb}, nc}] = v+1;
			q.push({{na, nb}, nc});
		}
		na = max(0, a-(B-b));
		nb = min(B, a+b);
		nc = c;
		if(mp[{{na, nb}, nc}]==0){
			mp[{{na, nb}, nc}] = v+1;
			q.push({{na, nb}, nc});
		}
		na = a;
		nb = min(B, c+b);
		nc = max(0, c-(B-b));
		if(mp[{{na, nb}, nc}]==0){
			mp[{{na, nb}, nc}] = v+1;
			q.push({{na, nb}, nc});
		}
		na = a;
		nb = max(0, b-(C-c));
		nc = min(C, c+b);
		if(mp[{{na, nb}, nc}]==0){
			mp[{{na, nb}, nc}] = v+1;
			q.push({{na, nb}, nc});
		}
		na = min(A, a+c);
		nb = b;
		nc = max(0, c-(A-a));
		if(mp[{{na, nb}, nc}]==0){
			mp[{{na, nb}, nc}] = v+1;
			q.push({{na, nb}, nc});
		}
		na = max(0, a-(C-c));
		nb = b;
		nc = min(C, c+a);
		if(mp[{{na, nb}, nc}]==0){
			mp[{{na, nb}, nc}] = v+1;
			q.push({{na, nb}, nc});
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin>>A>>B>>C;		
	int a, b, c;
	cin>>a>>b>>c;
	mp[{{a, b}, c}] = 1;
	solve(a, b, c);
	vector<int> wyn(C+1, 1e9);
	for(auto it:mp){
		int v = it.s;
		int a = it.f.f.f;
		wyn[a] = min(wyn[a], v);
		a = it.f.f.s;
		wyn[a] = min(wyn[a], v);
		a = it.f.s;
		wyn[a] = min(wyn[a], v);
	}
	for(auto it:wyn){
		if(it==1e9) cout<<-1<<" ";
		else cout<<it-1<<" ";
	}
	cout<<'\n';
	return 0;
}