-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc2002_toboggan.cpp
54 lines (49 loc) · 1.97 KB
/
aoc2002_toboggan.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
50
51
52
53
54
/* ************************************************************************** */
/* */
/* \\ /`/`` */
/* ~\o o_ 0 0\ */
/* / \__) (u ); _ _ */
/* / \/ \/ / \ \/ \/ \ */
/* /( . . ) ( )\ */
/* / \_____/ \_______/ \ */
/* [] [] [[] [[] *. */
/* []] []] [[] [[] */
/* */
/* ****************************************************************** nuo *** */
#include "iostream"
#include "sstream"
int main()
{
int count_1, count_2, i, n, a, b;
char c;
std::string temp;
std::string s;
count_1 = count_2 = 0;
while (std::getline(std::cin, temp))
{
std::stringstream ss(temp);
ss >> a;
if (ss.peek() == '-') ss.ignore();
ss >> b;
ss >> c;
if (ss.peek() == ':') ss.ignore();
ss >> s;
n = i = 0;
while (s[i])
{
if (c == s[i]) n++;
i++;
}
if (n <= b && n >= a) count_1++;
a--;
b--;
if (s[a] && s[b])
{
if (c == s[a] && c == s[b]) continue;
else if (c == s[a] || c == s[b]) count_2++;
}
}
std::cout << "Star 1 : " << count_1 << std::endl;
std::cout << "Star 2 : " << count_2 << std::endl;
return (0);
}