-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path10646.cpp
More file actions
33 lines (28 loc) · 775 Bytes
/
10646.cpp
File metadata and controls
33 lines (28 loc) · 775 Bytes
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
#include <iostream>
#include <deque>
#include <string>
using namespace std;
deque<string> deck;
int tc;
int val(string &card) {
if (card[0] >= '2' and card[0] <= '9') return card[0] - '0';
return 10;
}
int main() {
cin >> tc;
for (int t = 1; t <= tc; t++) {
deck.clear();
string in;
for (int i = 0; i < 52 - 25; i++) { cin >> in; deck.push_front(in); }
int y = 0;
for (int i = 0; i < 3; i++) {
string card = deck.front(); deck.pop_front();
y += val(card);
for (int j = 0; j < 10 - val(card); j++) deck.pop_front();
}
for (int i = 0; i < 25; i++) { cin >> in; deck.push_front(in); }
for (int i = 0; i < y - 1; i++) deck.pop_back();
cout << "Case " << t << ": " << deck.back() << endl;
}
return 0;
}