#include <bits/stdc++.h>
using namespace std;
map<string, int> mp = {{"H1", -50}, {"H2", -2}, {"H3", -3}, {"H4", -4}, {"H5", -5}, {"H6", -6}, {"H7", -7}, {"H8", -8}, {"H9", -9}, {"H10", -10}, {"H11", -20}, {"H12", -30}, {"H13", -40}};
int p, q, r, s;
int pp, qq, rr, ss;
int h1, h2, h3, h4;
void scan(int & x, string t[]) {
cin >> x;
for (int i = 1; i <= x; i++) cin >> t[i];
}
bool mutiple(int & x, string t[]) { return x == 1 && t[1] == "C10"; }
void count(int & x, string t[], int & l) {
int cnt = 0;
bool zhu = false, yang = false, fanbei = false;
for (int i = 1; i <= x; i++) {
if (t[i][0] == 'H') {
cnt++;
l += mp[t[i]];
} else if (t[i] == "S12") l -= 100, zhu = true;
else if (t[i] == "D11") l += 100, yang = true;
else if (t[i] == "C10") fanbei = true;
}
if (cnt == 13) l += 394;
if (cnt == 13 && zhu && yang) l = 500;
if (fanbei) l <<= 1;
if (l > 0) cout << "+";
cout << l << " ";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
while (1) {
pp = qq = rr = ss = 0;
string a[20], b[20], c[20], d[20];
scan(p, a); scan(q, b); scan(r, c); scan(s, d);
if (p + q + r + s == 0) exit(0);
if (mutiple(p, a)) pp = 50;
if (mutiple(q, b)) qq = 50;
if (mutiple(r, c)) rr = 50;
if (mutiple(s, d)) ss = 50;
// have all of the red hearts, than +394
// is also have sheep and pig, than +300
count(p, a, pp); count(q, b, qq); count(r, c, rr); count(s, d, ss);
cout << "\n";
}
return 0;
}
WA了 #1 #2 #3 #6 #8