-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path11225.cpp
More file actions
40 lines (34 loc) · 1.03 KB
/
11225.cpp
File metadata and controls
40 lines (34 loc) · 1.03 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
#include <iostream>
#include <string>
using namespace std;
int nOudlers, points, t, n, needed[4] = { 56, 51, 41, 36 };
string in;
bool isOudler(string &str) {
return str == "fool" or str == "twenty-one of trumps" or str == "one of trumps";
}
int point(string &str) {
if (str.find("king") != string::npos or isOudler(str)) return 9;
if (str.find("queen") != string::npos) return 7;
if (str.find("knight") != string::npos) return 5;
if (str.find("jack") != string::npos) return 3;
return 1;
}
int main() {
cin >> t;
for (int tc = 1; tc <= t; tc++) {
cin >> n;
nOudlers = points = 0;
getline(cin, in);
for (int i = 0; i < n; i++) {
getline(cin, in);
points += point(in);
nOudlers += isOudler(in);
}
points /= 2;
cout << "Hand #" << tc << endl;
if (points < needed[nOudlers]) cout << "Game lost by " << needed[nOudlers] - points << " point(s)." << endl;
else cout << "Game won by " << points - needed[nOudlers] << " point(s)." << endl;
if (tc != t) cout << endl;
}
return 0;
}