#include<bits/stdc++.h>
using namespace std;
int main()
{
map<char, int>mp;
mp['A'] = 4;
mp['K'] = 3;
mp['Q'] = 2;
mp['J'] = 1;
string s;
while(1)
{
deque<char>q[2], d;
for(int i=1;i<=52;i++)
{
cin >> s;
if(s == "#")
return 0;
q[i%2].push_front(s[1]);
}
int f = 1, last = -1, cnt = 0;
while(!q[f].empty())
{
char ch = q[f].front();
q[f].pop_front();
d.push_front(ch);
if(mp[ch])
{
last = f;
cnt = mp[ch] + 1;
f = (f+1)%2;
}
if(cnt)
{
cnt--;
if(cnt == 0)
{
while(!d.empty())
{
q[last].push_back(d.back());
d.pop_back();
}
f = last;
}
}
else
f = (f+1)%2;
}
f = (f+1)%2;
cout << f+1 << right << setw(3) << setfill(' ') << q[f].size() << "\n";
}
return 0;
}
Comments
Post a Comment