题解:P10457 占卜DIY
根据题意,我们可以把
献上我丑陋的代码。
#include<bits/stdc++.h>
using namespace std;
const int N=20;
deque<int> d[N];
int cnt[N];
int main(){
for(int i=1;i<=13;i++){
for(int j=0;j<4;j++){
char c;
cin>>c;
if(c>='1'&&c<='9'){
d[i].push_back(c-'0');
}else if(c=='0'){
d[i].push_back(10);
}else if(c=='J'){
d[i].push_back(11);
}else if(c=='Q'){
d[i].push_back(12);
}else if(c=='K'){
d[i].push_back(13);
}else{
d[i].push_back(1);
}
}
}
int ck=0,ans=0,key=d[13].front();
d[13].pop_front();
while(ck<4){
if(key==13){
ck++;
key=d[13].front();
d[13].pop_front();
continue;
}
d[key].push_front(key);
int tmp=key;
key=d[tmp].back();
d[tmp].pop_back();
cnt[tmp]++;
if(cnt[tmp]==4){
ans++;
}
}
cout<<ans;
return 0;
}