-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10205.cpp
53 lines (43 loc) · 1.46 KB
/
10205.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
#include <array>
#include <iostream>
#include <string>
int main(void)
{
int num_cases, num_shuffles;
std::string buffer;
std::array<int, 53> curr, prev;
std::array<std::array<int, 53>, 101> shuffles;
std::array<std::string, 4> card_suit{
{"Clubs", "Diamonds", "Hearts", "Spades"}};
std::array<std::string, 13> card_value{{"Ace", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "Jack", "Queen",
"King"}};
getline(std::cin, buffer);
num_cases = std::stoi(buffer);
getline(std::cin, buffer);
while (num_cases--) {
for (int i = 1; i < 53; ++i)
curr[i] = i;
std::cin >> num_shuffles;
for (int k = 1; k <= num_shuffles; ++k) {
for (int i = 1; i < 53; ++i)
std::cin >> shuffles[k][i];
}
getline(std::cin, buffer);
while (1) {
getline(std::cin, buffer);
if (!buffer.size()) break;
int k = std::stoi(buffer);
std::swap(curr, prev);
for (int i = 1; i < 53; ++i) {
curr[i] = prev[shuffles[k][i]];
}
}
for (int i = 1; i < 53; ++i) {
std::cout << card_value[curr[i] % 13] << " of "
<< card_suit[(curr[i] - 1) / 13] << std::endl;
}
if (num_cases) std::cout << std::endl;
}
return 0;
}