-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path210119_BOJ_10597.cpp
More file actions
64 lines (48 loc) · 960 Bytes
/
Copy path210119_BOJ_10597.cpp
File metadata and controls
64 lines (48 loc) · 960 Bytes
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
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string s;
int des = 0;
bool isFinished = false;
void findAnswer(int start, vector<bool> check, vector<int> answer) {
if (isFinished)
return;
if (answer.size() == des) {
for (int i = 0; i < des; ++i)
cout << answer[i] << " ";
cout << "\n";
isFinished = true;
}
string temp;
for (int i = start + 1; i < start + 3 && i < s.size(); ++i) {
temp += s[i];
int num = stoi(temp);
if (num > des)
continue;
if (!check[num]) {
vector<int> v = answer;
v.push_back(num);
check[num] = true;
findAnswer(i, check, v);
check[num] = false;
v.pop_back();
}
}
}
int main() {
cin >> s;
vector<bool> check;
if (s.size() <= 9) {
des = s.size();
check.assign(des + 1, false);
}
else {
des = 9 + (s.size() - 9) / 2;
check.assign(des + 1, false);
}
check[0] = true;
vector<int> answer;
findAnswer(-1, check, answer);
return 0;
}