The Seven-Sparkling-Star Card Game
Problem
The Seven-Sparkling-Star Card Game(七星卡牌)游戏是 Illumina_ 矿业无限游戏公司的最新力作。
基本游戏规则:
对战双方各持
胜负判定规则:
若在某一回合中,某一玩家行动完,对方血量小于等于
若双方的
卡牌介绍:
每张卡牌的属性(对解题有用的)有:攻击力
7张卡牌的攻击力结算:
自玩家选出了七张卡牌并分出主战斗区和辅助战斗区后,还需计算主战斗区中
1.同花五条,若
2.皇家同花顺,若
3.五条, 若
4.同花顺,若
5.同花四条,若
6.同花葫芦,若
7.四条,若
8.葫芦,若
9.同花三条,若
10.顺子,若
11.同花,若
12.同花两对,若
13.三条,若
14.两对,若
15.同花一对,若
16.一对,若
17.高牌,若这
最后,记
你的任务是给定两名玩家 Illumina_ 和 Sparkle_7 的卡牌数量 和初始血量 以及每回合所用的卡牌,其中
注1:如果牌局在某一回合结束,后续所有回合和将要使用的卡牌全部作废。
注2:牌型不可叠加计算,若同时满足多种牌型,取倍数高的计算。
注3:对于诸如“同花两对”、“同花一对”之类的牌型,仅需满足其对子或三条的部分为同花,剩余的牌可为任意牌。
注4:对于同花葫芦只要构成”同花葫芦“的”同花三条“和”同花一对“内部同花即可。
Input
第一行两个整数
接下来
每张卡牌的第一行包含 2 个正整数和一个字符(点数10用T表示,A,K,Q,J正常输入),
再接下来
Output
输出按以下几类处理:
若在某名玩家结束行动后,使得对方血量降至
若所有
否则,输出
Sample
Input 1
7 1261
23 2 4
21 2 Q
81 1 8
55 1 5
63 4 9
82 3 K
57 4 J
16 1 6
73 4 4
49 2 4
28 1 A
86 1 K
15 4 A
35 1 A
Output 1
Sparkle_7 1
Input 2
7 15555
0 1 A
0 1 A
0 1 A
0 1 A
0 1 A
1 2 4
1 6 8
57 1 7
44 3 T
15 3 4
22 3 2
16 1 6
46 4 J
88 3 J
Output 2
Illumina_ final
Solution
大模拟,有点恶心
思维难度不大,根据题意的情况依此判就行,主要是考代码功底
写的时候注意一些坑点:
1.有些情况所带来的增益是对于所有卡牌的,而有些只是对于主战区的卡牌增益
2.若同时满足多种牌型,取倍数高的计算,而不是选择总增益的最大的牌型。
Code
代码很长,但应该比较容易理解
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int kmax = 103;
struct Card {
int a, c, e;
};
struct Contest {
Card p[7];
} a[kmax], b[kmax];
int n, num[15][5];
long long ct;
int o[15];
long long al, bl, tot, tott;
char ch;
bool Check1(Contest c) {
sort(c.p, c.p + 7, [](Card p, Card q) { return p.e < q.e || p.e == q.e && p.c < q.c; });
for (int i = 0, j = 4; j < 7; i++, j++) {
bool b = 1;
for (int k = i + 1; k <= j; k++) {
b &= (c.p[k].c == c.p[k - 1].c);
b &= (c.p[k].e == c.p[k - 1].e);
}
if (b) return 1;
}
return 0;
}
bool Check2(Contest c) {
memset(num, 0, sizeof(num));
for (int i = 0; i < 7; i++) {
num[c.p[i].e][c.p[i].c]++;
}
for (int i = 1; i <= 4; i++) {
if (num[1][i] && num[10][i] && num[11][i] && num[12][i] && num[13][i]) return 1;
}
return 0;
}
bool Check3(Contest c) {
sort(c.p, c.p + 7, [](Card p, Card q) { return p.e < q.e || p.e == q.e && p.c < q.c; });
for (int i = 0, j = 4; j < 7; i++, j++) {
bool b = 1;
for (int k = i + 1; k <= j; k++) {
b &= (c.p[k].e == c.p[k - 1].e);
}
if (b) return 1;
}
return 0;
}
bool Check4(Contest c) {
memset(num, 0, sizeof(num));
for (int i = 0; i < 7; i++) {
num[c.p[i].e][c.p[i].c]++;
}
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= 13; j++) {
if (num[j][i] && num[j % 13 + 1][i] && num[(j + 1) % 13 + 1][i] && num[(j + 2) % 13 + 1][i] && num[(j + 3) % 13 + 1][i]) return 1;
}
}
return 0;
}
bool Check5(Contest c) {
sort(c.p, c.p + 7, [](Card p, Card q) { return p.e < q.e || p.e == q.e && p.c < q.c; });
for (int i = 0, j = 3; j < 7; i++, j++) {
bool b = 1;
for (int k = i + 1; k <= j; k++) {
b &= (c.p[k].c == c.p[k - 1].c);
b &= (c.p[k].e == c.p[k - 1].e);
}
if (b) return 1;
}
return 0;
}
bool Check6(Contest c) {
memset(num, 0, sizeof(num));
for (int i = 0; i < 7; i++) {
num[c.p[i].e][c.p[i].c]++;
}
bool b = 0, bb = 0;
for (int i = 1; i <= 13; i++) {
for (int j = 1; j <= 4; j++) {
if (num[i][j] >= 3) {
b = 1;
break;
}
if (num[i][j] >= 2) {
bb = 1;
break;
}
}
}
return b && bb;
}
bool Check7(Contest c) {
sort(c.p, c.p + 7, [](Card p, Card q) { return p.e < q.e || p.e == q.e && p.c < q.c; });
for (int i = 0, j = 3; j < 7; i++, j++) {
bool b = 1;
for (int k = i + 1; k <= j; k++) {
b &= (c.p[k].e == c.p[k - 1].e);
}
if (b) return 1;
}
return 0;
}
bool Check8(Contest c) {
memset(num, 0, sizeof(num));
for (int i = 0; i < 7; i++) {
num[c.p[i].e][0]++;
}
bool b = 0, bb = 0;
for (int i = 1; i <= 13; i++) {
if (num[i][0] >= 3) {
b = 1;
continue;
}
if (num[i][0] >= 2) {
bb = 1;
continue;
}
}
return b && bb;
}
bool Check9(Contest c) {
sort(c.p, c.p + 7, [](Card p, Card q) { return p.e < q.e || p.e == q.e && p.c < q.c; });
for (int i = 0, j = 2; j < 7; i++, j++) {
bool b = 1;
for (int k = i + 1; k <= j; k++) {
b &= (c.p[k].c == c.p[k - 1].c);
b &= (c.p[k].e == c.p[k - 1].e);
}
if (b) return 1;
}
return 0;
}
bool Check10(Contest c) {
tott = 0;
bool hhh = 0;
for (int i = 0; i < 7; i++) {
for (int j = i + 1; j < 7; j++) {
ct = 0;
memset(o, 0, sizeof(o));
for (int k = 0; k < 7; k++) {
if (i == k || j == k) continue;
o[c.p[k].e] = 1;
ct += c.p[k].a;
}
bool bb = 0;
for (int k = 1; k <= 13; k++) {
if (o[k] && o[k % 13 + 1] && o[(k + 1) % 13 + 1] && o[(k + 2) % 13 + 1] && o[(k + 3) % 13 + 1]) {
bb = 1;
}
}
if (bb) {
tott = max(tott, ct);
hhh = 1;
}
}
}
return hhh;
}
bool Check11(Contest c) {
tott = 0;
bool hhh = 0;
for (int i = 0; i < 7; i++) {
for (int j = i + 1; j < 7; j++) {
ct = 0;
memset(o, 0, sizeof(o));
for (int k = 0; k < 7; k++) {
if (i == k || j == k) continue;
o[c.p[k].c]++;
ct += c.p[k].a;
}
bool bb = 0;
for (int k = 1; k <= 4; k++) {
if (o[k] == 5) {
bb = 1;
}
}
if (bb) {
tott = max(tott, ct);
hhh = 1;
}
}
}
return hhh;
}
bool Check12(Contest c) {
tott = 0;
bool hhh = 0;
for (int i = 0; i < 7; i++) {
for (int j = i + 1; j < 7; j++) {
ct = 0;
memset(num, 0, sizeof(num));
for (int k = 0; k < 7; k++) {
if (i == k || j == k) continue;
num[c.p[k].e][c.p[k].c]++;
ct += c.p[k].a;
}
int b = 0;
for (int i = 1; i <= 13; i++) {
for (int j = 1; j <= 4; j++) {
if (num[i][j] >= 2) {
b++;
}
}
}
if (b >= 2) {
tott = max(tott, ct);
hhh = 1;
}
}
}
return hhh;
}
bool Check13(Contest c) {
tott = 0;
bool hhh = 0;
for (int i = 0; i < 7; i++) {
for (int j = i + 1; j < 7; j++) {
ct = 0;
memset(o, 0, sizeof(o));
for (int k = 0; k < 7; k++) {
if (i == k || j == k) continue;
o[c.p[k].e]++;
ct += c.p[k].a;
}
bool bb = 0;
for (int k = 1; k <= 13; k++) {
if (o[k] >= 3) {
bb = 1;
}
}
if (bb) {
tott = max(tott, ct);
hhh = 1;
}
}
}
return hhh;
}
bool Check14(Contest c) {
tott = 0;
bool hhh = 0;
for (int i = 0; i < 7; i++) {
for (int j = i + 1; j < 7; j++) {
ct = 0;
memset(num, 0, sizeof(num));
for (int k = 0; k < 7; k++) {
if (i == k || j == k) continue;
num[c.p[k].e][0]++;
ct += c.p[k].a;
}
int b = 0;
for (int i = 1; i <= 13; i++) {
if (num[i][0] >= 2) {
b++;
}
}
if (b >= 2) {
tott = max(tott, ct);
hhh = 1;
}
}
}
return hhh;
}
bool Check15(Contest c) {
tott = 0;
bool hhh = 0;
for (int i = 0; i < 7; i++) {
for (int j = i + 1; j < 7; j++) {
ct = 0;
memset(num, 0, sizeof(num));
for (int k = 0; k < 7; k++) {
if (i == k || j == k) continue;
num[c.p[k].e][c.p[k].c]++;
ct += c.p[k].a;
}
int b = 0;
for (int i = 1; i <= 13; i++) {
for (int j = 1; j <= 4; j++) {
if (num[i][j] >= 2) {
b++;
}
}
}
if (b >= 1) {
tott = max(tott, ct);
hhh = 1;
}
}
}
return hhh;
}
bool Check16(Contest c) {
tott = 0;
bool hhh = 0;
for (int i = 0; i < 7; i++) {
for (int j = i + 1; j < 7; j++) {
ct = 0;
memset(num, 0, sizeof(num));
for (int k = 0; k < 7; k++) {
if (i == k || j == k) continue;
num[c.p[k].e][0]++;
ct += c.p[k].a;
}
int b = 0;
for (int i = 1; i <= 13; i++) {
if (num[i][0] >= 2) {
b++;
}
}
if (b >= 1) {
tott = max(tott, ct);
hhh = 1;
}
}
}
return hhh;
}
void Solve(Contest c, long long &h) {
tot = tott = 0;
for (int i = 0; i < 7; i++) {
tot += c.p[i].a;
}
if (Check1(c)) {
h -= tot * 7777;
} else if (Check2(c)) {
h -= tot * 2000;
} else if (Check3(c)) {
h -= tot * 1000;
} else if (Check4(c)) {
h -= tot * 888;
} else if (Check5(c)) {
h -= tot * 777;
} else if (Check6(c)) {
h -= tot * 666;
} else if (Check7(c)) {
h -= tot * 500;
} else if (Check8(c)) {
h -= tot * 343;
} else if (Check9(c)) {
h -= tot * 200;
} else if (Check10(c)) {
h -= tott * 100 - (tot - tott);
} else if (Check11(c)) {
h -= tott * 50 - (tot - tott);
} else if (Check12(c)) {
h -= tott * 20 - (tot - tott);
} else if (Check13(c)) {
h -= tott * 10 - (tot - tott);
} else if (Check14(c)) {
h -= tott * 7 - (tot - tott);
} else if (Check15(c)) {
h -= tott * 5 - (tot - tott);
} else if (Check16(c)) {
h -= tott * 2 - (tot - tott);
} else {
h -= tot;
}
}
int main() {
// freopen("illumina.in", "r", stdin);
// freopen("illumina.out", "w", stdout);
scanf("%d%lld", &n, &al);
bl = al;
for (int i = 1; i <= n / 7; i++) {
for (int j = 0; j < 7; j++) {
scanf("%d %d %c", &a[i].p[j].a, &a[i].p[j].c, &ch);
if (ch == 'A') a[i].p[j].e = 1;
if (ch == 'T') a[i].p[j].e = 10;
if (ch == 'J') a[i].p[j].e = 11;
if (ch == 'Q') a[i].p[j].e = 12;
if (ch == 'K') a[i].p[j].e = 13;
if (ch >= '2' && ch <= '9') a[i].p[j].e = ch - '0';
}
}
for (int i = 1; i <= n / 7; i++) {
for (int j = 0; j < 7; j++) {
scanf("%d %d %c", &b[i].p[j].a, &b[i].p[j].c, &ch);
if (ch == 'A') b[i].p[j].e = 1;
if (ch == 'T') b[i].p[j].e = 10;
if (ch == 'J') b[i].p[j].e = 11;
if (ch == 'Q') b[i].p[j].e = 12;
if (ch == 'K') b[i].p[j].e = 13;
if (ch >= '2' && ch <= '9') b[i].p[j].e = ch - '0';
}
}
for (int i = 1; i <= n / 7; i++) {
Solve(a[i], bl);
if (bl <= 0) {
printf("Illumina_ ");
printf("%d\n", i);
return 0;
}
Solve(b[i], al);
if (al <= 0) {
printf("Sparkle_7 ");
printf("%d\n", i);
return 0;
}
}
if (al < bl) printf("Sparkle_7 final");
if (al == bl) printf("Tie");
if (al > bl) printf("Illumina_ final");
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】