forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwelcomeeasy.cpp
49 lines (39 loc) · 930 Bytes
/
welcomeeasy.cpp
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
#include <iostream>
#include <string>
using namespace std;
int total = 0;
void solve(int loc, int target, string& s, string& match) {
if(target == match.length()) {
total++;
return;
}
for(int i = loc; i < s.length(); i++) {
if(match[target] == s[i]) {
solve(i+1, target+1, s, match);
}
}
return;
}
int main() {
int n;
cin >> n;
cin.ignore();
for(int i = 1; i <= n; i++) {
// Read input
string s;
getline(cin, s);
// Solve the problem
string match = "welcome to code jam";
solve(0, 0, s, match);
// Make exactly 4 characters
string t = to_string(total);
while(t.length() > 4) {
t.erase(0, 1);
}
while(t.length() < 4) {
t.insert(0, 1, '0');
}
cout << "Case #" << i << ": " << t << endl;
total = 0;
}
}