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
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <bits/stdc++.h>
using namespace std;
int A, B, C, t = 0 ,a, b, c, ile = 0;
int wyn[100001];
set<pair<int,int> > parycd[100001];
queue<int> ka, kb, kc, kczas;
void przelejza(int a, int b, int c, int czas){//z a
	int temp, na, nb, nc, r;
		temp = a;
		r = B- b;
		na = max(a - r, 0);
		nb = min(B, a + b); 
		nc = c;
		if(wyn[na] == C + 1) { wyn[na] = czas + 1; ile++;}
		if(wyn[nb] == C + 1) { wyn[nb] = czas + 1; ile++;}
		if(wyn[nc] == C + 1)  { wyn[nc] = czas + 1;ile++;}
		if(parycd[na].find(make_pair(nb,nc)) == parycd[na].end()){
			parycd[na].insert(make_pair(nb,nc));
			ka.push(na);kb.push(nb);kc.push(nc);kczas.push(czas + 1);
			//cout << na <<" " <<nb <<" "<<nc << endl;
		}
		
		
		r = C - c;
		na = max(a - r, 0);
		nb = b;
		nc = min(C, a + c);
		if(wyn[na] == C + 1) { wyn[na] = czas + 1; ile++;}
		if(wyn[nb] == C + 1) { wyn[nb] = czas + 1; ile++;}
		if(wyn[nc] == C + 1)  { wyn[nc] = czas + 1;ile++;}
		if(parycd[na].find(make_pair(nb,nc)) == parycd[na].end()){
			parycd[na].insert(make_pair(nb,nc));
			ka.push(na);kb.push(nb);kc.push(nc);kczas.push(czas + 1);
			//cout << na <<" " <<nb <<" "<<nc << endl;
		}
		
}
void przelejzb(int a, int b, int c, int czas){//z b
	int temp, na, nb, nc, r;
		temp = b;
		r = A - a;
		na = min(A,a + b);
		nb =  max(b - r,0); 
		nc = c;
		if(wyn[na] == C + 1) { wyn[na] = czas + 1; ile++;}
		if(wyn[nb] == C + 1) { wyn[nb] = czas + 1; ile++;}
		if(wyn[nc] == C + 1)  { wyn[nc] = czas + 1;ile++;}
		if(parycd[na].find(make_pair(nb,nc)) == parycd[na].end()){
			parycd[na].insert(make_pair(nb,nc));
			ka.push(na);kb.push(nb);kc.push(nc);kczas.push(czas + 1);
			//cout << na <<" " <<nb <<" "<<nc << endl;
		}
			

		r = C- c;
		na = a;
		nb =  max(b - r,0);
		nc = min(C, c + b);
		if(wyn[na] == C + 1) { wyn[na] = czas + 1; ile++;}
		if(wyn[nb] == C + 1) { wyn[nb] = czas + 1; ile++;}
		if(wyn[nc] == C + 1)  { wyn[nc] = czas + 1;ile++;}
		if(parycd[na].find(make_pair(nb,nc)) == parycd[na].end()){
			parycd[na].insert(make_pair(nb,nc));
			ka.push(na);kb.push(nb);kc.push(nc);kczas.push(czas + 1);
			//cout << na <<" " <<nb <<" "<<nc << endl;
		}
}
void przelejzc(int a, int b, int c, int czas){//z c
	int temp, na, nb, nc, r;
		temp = c;
		r = A - a;
		na = min(A, a + c);
		nb = b; 
		nc = max(c-r,0);
		if(wyn[na] == C + 1) { wyn[na] = czas + 1; ile++;}
		if(wyn[nb] == C + 1) { wyn[nb] = czas + 1; ile++;}
		if(wyn[nc] == C + 1)  { wyn[nc] = czas + 1;ile++;}
		if(parycd[na].find(make_pair(nb,nc)) == parycd[na].end()){
			parycd[na].insert(make_pair(nb,nc));
			ka.push(na);kb.push(nb);kc.push(nc);kczas.push(czas + 1);
			//cout << na <<" " <<nb <<" "<<nc << endl;
		}
			
		r = B -b;
		na = a;
		nb = min(B, c + b);
		nc = max(c - r,0);
		if(wyn[na] == C + 1) { wyn[na] = czas + 1; ile++;}
		if(wyn[nb] == C + 1) { wyn[nb] = czas + 1; ile++;}
		if(wyn[nc] == C + 1)  { wyn[nc] = czas + 1;ile++;}
		if(parycd[na].find(make_pair(nb,nc)) == parycd[na].end()){
			parycd[na].insert(make_pair(nb,nc));
			ka.push(na);kb.push(nb);kc.push(nc);kczas.push(czas + 1);
			//cout << na <<" " <<nb <<" "<<nc << endl;
		}			
}
void bfs(int a, int b , int c){
	
	ka.push(a);kb.push(b);kc.push(c),kczas.push(t);
	wyn[a] = 0; ile++; if(wyn[b] == C + 1) ile++; wyn[b] = 0; if(wyn[c] == C + 1) ile++; wyn[c] = 0;
	parycd[a].insert(make_pair(b,c));
	while(!ka.empty()){
		int ap = ka.front(), bp = kb.front(), cp = kc.front(),czasp = kczas.front();
		ka.pop();kb.pop();kc.pop();kczas.pop();
		przelejza(ap, bp, cp, czasp);
		przelejzb(ap, bp, cp, czasp);
		przelejzc(ap, bp, cp, czasp);
		if(ile == C + 1) break;
	}
}
int main() {
	ios_base::sync_with_stdio(0);
	int n, i, j;
	cin >> A >> B >> C;
	cin >> a >> b >> c;
	for(i = 0; i <= C; i++) wyn[i] = C + 1;
	bfs(a, b, c);
	for(i = 0; i <= C; i++) if(wyn[i] == C + 1) cout << -1 <<" ";
							else cout << wyn[i] <<" ";
	
	

	
	return 0;
}