模拟:
分数历程:
0
→
55
0 \to 55
0→55:删了调试
55
→
82
55 \to 82
55→82:碰了过后出牌的顺序从碰的人开始往后
82
→
91
82 \to 91
82→91:王炸我处理的是 3 张,改成了 2 张
91
→
100
91 \to 100
91→100:王炸
<
<
< 777
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline void read(int &x)
{
x = 0;
int f = 0;
char ch = getchar();
while(ch < '0' || ch > '9')
{
f |= ch == '-';
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x = x * 10 + ch - 48;
ch = getchar();
}
x = f ? -x : x;
return;
}
#define N 5
struct card
{
int pai[21], cnt;
};
card a[N];
int n;
inline int turn(char s)
{
if(s == '4')
{
return 1;
}
if(s == '6')
{
return 2;
}
if(s == '8')
{
return 3;
}
if(s == '9')
{
return 4;
}
if(s == 'X')
{
return 5;
}
if(s == 'J')
{
return 6;
}
if(s == 'Q')
{
return 7;
}
if(s == 'K')
{
return 8;
}
if(s == 'A')
{
return 9;
}
if(s == '3')
{
return 10;
}
if(s == '2')
{
return 11;
}
if(s == '5')
{
return 12;
}
if(s == 'F')
{
return 13;
}
if(s == 'G')
{
return 14;
}
if(s == '7')
{
return 15;
}
return -1;
}
queue<int> q;
char s[105];
inline void init()
{
read(n);
scanf("%s", s + 1);
for(int len = 1; s[len]; len++)
{
q.push(turn(s[len]));
}
for(int i = 1; i <= 6; i++)
{
a[1].pai[q.front()]++;
a[1].cnt++;
q.pop();
}
for(int i = 2; i <= n; i++)
{
for(int j = 1; j <= 5; j++)
{
a[i].pai[q.front()]++;
a[i].cnt++;
q.pop();
}
}
return;
}
int ans[N];
struct chupai
{
int val, num;
};
chupai get(int id, chupai x)
{
for(int i = x.val + 1; i <= 15; i++)
{
if(x.num == 1 && i >= 13 && i <= 14)
{
if(a[id].pai[13] + a[id].pai[14] == 2)
{
continue;
}
}
if(x.num == 3 && i == 14 && a[id].pai[13] && a[id].pai[14])
{
a[id].cnt -= 2;
a[id].pai[13] = 0;
a[id].pai[14] = 0;
return (chupai){14, 3};
}
if(a[id].pai[i] == x.num)
{
a[id].cnt -= a[id].pai[i];
a[id].pai[i] = 0;
return (chupai){i, x.num};
}
}
for(int numb = max(x.num + 1, 3); numb <= 4; numb++)
{
for(int i = 1; i <= 15; i++)
{
if(a[id].pai[i] == numb)
{
a[id].cnt -= a[id].pai[i];
a[id].pai[i] = 0;
return (chupai){i, numb};
}
if(i == 14 && numb == 3)
{
if(a[id].pai[13] && a[id].pai[14])
{
a[id].cnt -= 2;
a[id].pai[13] = 0;
a[id].pai[14] = 0;
return (chupai){14, 3};
}
}
}
}
return (chupai){0, 0};
}
chupai getfirst(int id)
{
for(int i = 1; i <= 14; i++)
{
if(a[id].pai[i] == 2)
{
a[id].cnt -= 2;
a[id].pai[i] = 0;
return (chupai){i, 2};
}
}
for(int i = 1; i <= 15; i++)
{
if(i >= 13 && i <= 14)
{
if(a[id].pai[13] + a[id].pai[14] == 2)
{
continue;
}
}
if(a[id].pai[i] == 1)
{
a[id].cnt -= 1;
a[id].pai[i] = 0;
return (chupai){i, 1};
}
}
if(a[id].pai[15] == 2)
{
a[id].cnt -= 2;
a[id].pai[15] = 0;
return (chupai){15, 2};
}
for(int i = 1; i <= 15; i++)
{
if(a[id].pai[i] == 3)
{
a[id].cnt -= 3;
a[id].pai[i] = 0;
return (chupai){i, 3};
}
if(i == 14)
{
if(a[id].pai[13] && a[id].pai[14])
{
a[id].cnt -= 2;
a[id].pai[13] = 0;
a[id].pai[14] = 0;
return (chupai){14, 3};
}
}
}
for(int i = 1; i <= 15; i++)
{
if(a[id].pai[i] == 4)
{
a[id].cnt -= 4;
a[id].pai[i] = 0;
return (chupai){i, 4};
}
}
return (chupai){0, 0};
}
inline bool check()
{
int flag = 0;
for(int i = 1; i <= n; i++)
{
flag |= !a[i].cnt;
}
return !(flag && q.empty());
}
inline void round()
{
int tot, player = 1, i;
chupai last, now;
while(check())
{
last = getfirst(player);
tot = last.num;
if(last.val == 14 && last.num == 3)
{
tot--;
}
i = player;
while(last.num)
{
if(last.num == 1)
{
for(i++; ; i++)
{
if(i == n + 1)
{
i = 1;
}
if(i == player)
{
break;
}
if(a[i].pai[last.val] == 2)
{
a[i].cnt -= 2;
a[i].pai[last.val] = 0;
last = (chupai){16, 2};
player = i;
break;
}
}
if(last.num == 2)
{
tot += 2;
continue;
}
}
now = (chupai){0, 0};
for(i++; ; i++)
{
if(i == n + 1)
{
i = 1;
}
if(i == player)
{
break;
}
now = get(i, last);
if(now.num)
{
if(now.val == 14 && now.num == 3)
{
tot--;
}
tot += now.num;
player = i;
break;
}
}
last = now;
}
//printf("winner:%d score: %d\n", player, tot);
ans[player] += tot;
while(a[player].cnt != 5 && !q.empty())
{
a[player].cnt++;
a[player].pai[q.front()]++;
q.pop();
}
for(i++; ; i++)
{
if(i == n + 1)
{
i = 1;
}
if(i == player)
{
break;
}
while(a[i].cnt != 5 && !q.empty())
{
a[i].cnt++;
a[i].pai[q.front()]++;
q.pop();
}
}
}
return;
}
signed main()
{
//freopen("data.in", "r", stdin);
init();
round();
for(int i = 1; i <= n; i++)
{
printf("%d\n", ans[i] + a[i].cnt);
}
return 0;
}