-
Notifications
You must be signed in to change notification settings - Fork 65
/
10415 Saxophone Player.cpp
98 lines (84 loc) · 2.28 KB
/
10415 Saxophone Player.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <vector>
#include <string>
#include <iostream>
using namespace std;
inline void Check(int pos, vector<bool> & previousPressed, vector<int> & counts)
{
if (!previousPressed[pos])
++counts[pos];
}
void ChangeNote(const char & note, vector<bool> & previousPressed, vector<int> & counts)
{
vector<bool> newPressed(11, false);
switch (note)
{
case 'C':
Check(3, previousPressed, counts);
newPressed[3] = true;
break;
case 'c':
Check(10, previousPressed, counts);
newPressed[10] = true;
case 'd':
Check(9, previousPressed, counts);
newPressed[9] = true;
case 'e':
Check(8, previousPressed, counts);
newPressed[8] = true;
case 'f':
Check(7, previousPressed, counts);
newPressed[7] = true;
case 'g':
Check(4, previousPressed, counts);
newPressed[4] = true;
case 'a':
Check(3, previousPressed, counts);
newPressed[3] = true;
case 'b':
Check(2, previousPressed, counts);
newPressed[2] = true;
break;
case 'D':
Check(9, previousPressed, counts);
newPressed[9] = true;
case 'E':
Check(8, previousPressed, counts);
newPressed[8] = true;
case 'F':
Check(7, previousPressed, counts);
newPressed[7] = true;
case 'G':
Check(4, previousPressed, counts);
newPressed[4] = true;
case 'A':
Check(3, previousPressed, counts);
newPressed[3] = true;
case 'B':
Check(2, previousPressed, counts);
newPressed[2] = true;
Check(1, previousPressed, counts);
newPressed[1] = true;
break;
}
previousPressed.swap(newPressed);
}
int main()
{
vector<int> counts(11);
string phrase;
int T;
cin >> T;
cin.ignore();
while (T--)
{
for (int i = 1; i < 11; ++i)
counts[i] = 0;
getline(cin, phrase);
vector<bool> previousPressed(11, false);
for (int i = 0; i < phrase.size(); ++i)
ChangeNote(phrase[i], previousPressed, counts);
for (int i = 1; i < 10; ++i)
cout << counts[i] << ' ';
cout << counts[10] << '\n';
}
}