#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const int MAX = 201;
int water[MAX][MAX][MAX];
int A, B, C;
vector<int> answer;
void bfs() {
queue<pair<pair<int, int>, int>> q;
q.push(make_pair(make_pair(0, 0),C));
while (!q.empty()) {
int a = q.front().first.first;
int b = q.front().first.second;
int c = q.front().second;
q.pop();
if (water[a][b][c] == 1)
continue;
if (a == 0)
answer.push_back(c);
water[a][b][c] = 1;
if (a + b > B)
q.push(make_pair(make_pair(a - (B - b),B), c));
else
q.push(make_pair(make_pair(0, b+a), c));
if (b + c > C)
q.push(make_pair(make_pair(a, b-(C-c)), C));
else
q.push(make_pair(make_pair(a, 0), c + b));
if (c + a > A)
q.push(make_pair(make_pair(A, b), c-(A-a)));
else
q.push(make_pair(make_pair(a+c, b ), 0));
if (a + c > C)
q.push(make_pair(make_pair(a - (C - c), b), C));
else
q.push(make_pair(make_pair(0, b), c+a));
if (a + b > A)
q.push(make_pair(make_pair(A, b-(A-a)), c));
else
q.push(make_pair(make_pair(a+b, 0), c));
if (c + b > B)
q.push(make_pair(make_pair(a, B), c-(B-b)));
else
q.push(make_pair(make_pair(a, b+c), 0));
}
return;
}
int main(void) {
cin >> A >> B >> C;
bfs();
sort(answer.begin(),answer.end());
for (int i = 0; i < answer.size(); i++)
cout << answer[i] << " ";
return 0;
}
'백준 알고리즘 > BFS' 카테고리의 다른 글
백준 16234번 C++ (0) | 2019.10.09 |
---|---|
백준 5427번 C++ (0) | 2019.08.21 |
백준 1325번 C++ (0) | 2019.08.20 |
백준 1967번 C++ (0) | 2019.08.19 |
백준 9019번 C++ (0) | 2019.08.18 |