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
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int a,b,c,x,y,z,dis[N];
queue<array<int,3>> q;
map<array<int,3>,int> hs;
int main() {
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d%d%d",&x,&y,&z);
	rep(i,0,c+1) dis[i]=1<<30;
	q.push({x,y,z});
	hs[{x,y,z}]=0;
	while (!q.empty()) {
		auto p=q.front(); q.pop();
		int d=hs[p];
		rep(j,0,3) dis[p[j]]=min(dis[p[j]],d);
		int u,v;
		auto gao=[&](int a,int b,int f,int g,int &u,int &v) {
			int d=min(f,b-g);
			u=f-d; v=g+d;
		};
		auto add=[&](array<int,3> a) {
			if (!hs.count(a)) {
				hs[a]=d+1;
				q.push(a);
			}
		};
		gao(a,b,p[0],p[1],u,v);
		add({u,v,p[2]});
		gao(b,a,p[1],p[0],u,v);
		add({v,u,p[2]});
		gao(a,c,p[0],p[2],u,v);
		add({u,p[1],v});
		gao(c,a,p[2],p[0],u,v);
		add({v,p[1],u});
		gao(b,c,p[1],p[2],u,v);
		add({p[0],u,v});
		gao(c,b,p[2],p[1],u,v);
		add({p[0],v,u});
	}
	rep(i,0,c+1) printf("%d%c",(dis[i]==(1<<30)?-1:dis[i])," \n"[i==c]);
}