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
#include <iostream>
#include <queue>
#include <tuple>
#include <utility>
#include <map>

const int MAX = 100000;
const int INF = 1000000000;

int a, b, c;
std::map<std::tuple<int,int,int>, int> M;
int C[MAX];

void move(int& src, int& dst, int dst_size) {
  int ndst = std::min((src+dst), dst_size);
  src += dst-ndst;
  dst = ndst;
}

std::tuple<int, int, int> f1(int x, int y, int z) {
  move(x, y, b);
  return {x, y, z};
}
std::tuple<int, int, int> f2(int x, int y, int z) {
  move(y, x, a);
  return {x, y, z};
}
std::tuple<int, int, int> f3(int x, int y, int z) {
  move(x, z, c);
  return {x, y, z};
}
std::tuple<int, int, int> f4(int x, int y, int z) {
  move(z, x, a);
  return {x, y, z};
}
std::tuple<int, int, int> f5(int x, int y, int z) {
  move(y, z, c);
  return {x, y, z};
}
std::tuple<int, int, int> f6(int x, int y, int z) {
  move(z, y, b);
  return {x, y, z};
}

void BFS(int x, int y, int z) {
  std::queue<std::tuple<int, int, int>> Q;
  for (int i=0;i<=c;++i) C[i] = INF;
  Q.push({x,y,z});
  M[{x,y,z}] = 0;
  C[x] = 0;
  C[y] = 0;
  C[z] = 0;
  while (!Q.empty()) {
    auto [x,y,z] = Q.front();
    Q.pop();
    for (auto f : {f1, f2, f3, f4, f5, f6}) {
      auto [u, v, w] = f(x,y,z);
      if (M.find({u,v,w}) == M.end()) {
        int d = M[{u,v,w}] = M[{x,y,z}]+1;
        C[u] = std::min(C[u], d);
        C[v] = std::min(C[v], d);
        C[w] = std::min(C[w], d);
        Q.push({u,v,w});
      }
    }
  }
}

int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin >> a >> b >> c;
  int x, y, z;
  std::cin >> x >> y >> z;
  BFS(x,y,z);
  for (int i=0;i<=c;++i) std::cout << " " << (C[i]==INF?-1:C[i]);
  return 0;
}