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
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int A[3];
int a[3];

map<tuple<int,int,int>, int> m;
queue<array<int, 4> > q;

const int t[6][3] = {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}};

void f(){
	int tmp[3];
	while(!q.empty()){
		auto x = q.front();
		q.pop();
		for(int i=0; i<6; i++){
			tmp[0]=0;tmp[1]=0;tmp[2]=0;
			tmp[t[i][2]]=x[t[i][2]];
			tmp[t[i][1]]=min(A[t[i][1]], x[t[i][1]] + x[t[i][0]]);
			tmp[t[i][0]]=max(0, x[t[i][0]] - (A[t[i][1]] - x[t[i][1]]));
			auto tt = make_tuple(tmp[0], tmp[1], tmp[2]);
			auto itm = m.find(tt);
			if(itm == m.end()){
				m.insert(make_pair(tt, x[3]+1));
				array<int, 4> arr = {tmp[0], tmp[1], tmp[2], x[3]+1};
				q.push(arr);
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin>>A[0]>>A[1]>>A[2];
	cin>>a[0]>>a[1]>>a[2];
	array<int, 4> arr = {a[0],a[1],a[2], 0};
	q.push(arr);
	m.insert(make_pair(make_tuple(a[0],a[1],a[2]),0));
	f();
	vector <int> v;
	for(int i=0; i<=A[2]; i++){
		v.push_back(-1);
	}
	for(auto a : m){
		if(v[get<0>(a.first)] == -1 || v[get<0>(a.first)] > a.second){
			v[get<0>(a.first)]=a.second;
		}if(v[get<1>(a.first)] == -1 || v[get<1>(a.first)] > a.second){
			v[get<1>(a.first)]=a.second;
		}if(v[get<2>(a.first)] == -1 || v[get<2>(a.first)] > a.second){
			v[get<2>(a.first)]=a.second;
		}
	}
	for(auto a : v){
		cout<<a<<" ";
	}
	cout<<"\n";
	return 0;
}