-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·60 lines (53 loc) · 1.19 KB
/
Copy pathsol.cpp
File metadata and controls
executable file
·60 lines (53 loc) · 1.19 KB
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;
bool check(char a, char b, char c) {
string tmp;
tmp += a;
tmp += b;
tmp += c;
return (tmp == "BLR") || (tmp == "LBR") || (tmp == "RBL") || (tmp == "BRL") || (tmp == "LRB") || (tmp == "RLB");
}
int main() {
string s;
cin >> s;
string out;
vector<int> matches;
int i = 0;
if (s.length() >= 3) {
while (i < s.length() - 2) {
if (check(s.at(i), s.at(i+1), s.at(i+2))) {
matches.push_back(i);
i += 3;
} else {
i++;
}
}
}
i = 0;
int j = 0;
bool skip = false;
while (i < s.length()) {
if (j < matches.size()) {
if (matches[j] == i) {
out += 'C';
j++;
i += 3;
skip = true;
}
}
if (!skip) {
if (s.at(i) == 'R') {
out += 'S';
} else if (s.at(i) == 'B') {
out += 'K';
} else {
out += 'H';
}
i++;
} else {
skip = false;
}
}
cout << out << endl;
return 0;
}