AcWing 117. 占卜DIY(双端队列)
原题链接
简单
作者:
@谁是凶手1703
,
2020-03-27 19:31:59
,
所有人可见
,
阅读 1262
#include <bits/stdc++.h>
using namespace std;
const int N = 14;
int st[N];
deque<int> q[N];
int main()
{
for (int i = 1; i <= 13; i++)
for (int j = 1; j <= 4; j++)
{
char x;
cin >> x;
if (x - '0' < 10 && x-'0'!=0)
q[i].push_back((x - '0'));
else
{
if(x=='0')
q[i].push_back(10);
if (x == 'A')
q[i].push_back(1);
if (x == 'J')
q[i].push_back(11);
if (x == 'Q')
q[i].push_back(12);
if (x == 'K')
q[i].push_back(13);
}
}
int cnt = 0;
//取第一次
int t = q[13].front();
q[13].pop_front();
int ans=0;
while (cnt<4)
{
//printf("**%d**\n",cnt);
//当为K时
if (t == 13)
{
cnt++;
t = q[13].front();
q[13].pop_front();
continue;
}
//不为K时把其放在排顶
q[t].push_front(t);
int it=t;
//取排底操作
t = q[it].back();
q[it].pop_back();
st[it]++;
if(st[it]==4) ans++;
}
cout<<ans<<endl;
return 0;
}
qpzc
前排资瓷!
感谢 铁汁
哈?同学怎么了
;dts ecapseman gnisu