题面:占卜DIY
思路:
没什么好说的,就纯粹的模拟。
注意:
0
0
0 代表的是
10
10
10
代码:
#include <bits/stdc++.h>
#define sc scanf
#define pf printf
using namespace std;
deque<string> q[20];
map<string, int> vis;
int check(string x)
{
if(x == "A") return 1;
if(x == "J") return 11;
if(x == "Q") return 12;
if(x == "K") return 13;
char y = x[0];
if(y == '0') return 10;
return y - '0';
}
int main()
{
for(int i = 1; i <= 13; i++) {
for(int j = 0; j < 4; j++) {
string c;
cin >> c;
q[i].push_back(c);
}
}
while(true) {
if(vis["K"] == 4 || q[13].empty()) break;
auto t = q[13].front();
q[13].pop_front();
vis[t]++;
if(t == "K") continue;
bool flag = true;
while(flag) {
int k = check(t);
q[k].push_front(t);
t = q[k].back();
q[k].pop_back();
vis[t]++;
if(t == "K") {flag = false; continue;}
}
if(!flag) continue;
}
int cnt = 0;
vis.erase("K");
for(map<string, int>::iterator it = vis.begin(); it != vis.end(); ++it)
if(it->second == 4) cnt++;
pf("%d\n", cnt);
return 0;
}