#include <iostream>
using namespace std;
struct Player {
int k, d, p, hp; //兄弟先开个player存一下
Player() : k(0), d(0), p(0), hp(4) {} //题目给出滴,初始化一下咯
};
string howtosolve(int n, string s) {
//这个就是运行逻辑,题目给啥你写啥
Player peppa, george;
int i = 0; // 摸第几张牌
bool is_peppa_turn = true; //标一下到谁了
while (true) {
Player ¤t = is_peppa_turn ? peppa : george;
Player &opponent = is_peppa_turn ? george : peppa;
//看看出牌的玩家和对手的玩家
if (i < n) {
char c = s[i++];
if (c == 'K') current.k++;
else if (c == 'D') current.d++;
else current.p++;
}
//兄弟摸牌存一下
bool kill_happened = false; //你杀了吗?
if (current.k > 0) {
current.k--;
//兄弟我有杀我必须立刻打出,否则就不符题意了,刀剑无眼,兄弟莫怪
if (opponent.d > 0) {
opponent.d--;
//兄弟看你有没有闪
} else {
opponent.hp--;
//大意了
}
if (opponent.hp <= 0) {
//兄弟你没hp了
if (opponent.p > 0) {
opponent.p--;
opponent.hp++;
//磕个桃
} else {
return is_peppa_turn ? "Peppa" : "George";
//仍然是你
}
}
}
if (current.hp < 4 && current.p > 0) {
current.p--;
current.hp++;
}
//磕个桃
int total = current.k + current.d + current.p;
//记个牌,一会看看要不要弃牌
if (total > current.hp) {
int delta = total - current.hp;
int discard = min(delta, current.d);
current.d -= discard;
delta -= discard;
if (delta > 0) {
discard = min(delta, current.p);
current.p -= discard;
delta -= discard;
}
if (delta > 0) {
current.k -= delta;
}
}
//题目之意:若手牌数大于血量,则弃牌直到手牌数等于血量,有闪则优先弃置闪,无闪则弃置桃
if (i >= n) {
bool peppa_cannot = (peppa.k == 0) && (peppa.hp == 4 || peppa.p == 0);
bool george_cannot = (george.k == 0) && (george.hp == 4 || george.p == 0);
if (peppa_cannot && george_cannot) {
return "Draw";
}
}
//握手、握握双手
is_peppa_turn = !is_peppa_turn;
//一个人出完了,换个人了
}
}
int main() {
int T;cin >> T; //测试用例数
while (T--) {
int n;
string s;
cin >> n >> s;
cout << howtosolve(n, s) << '\n';
}
return 0;
}
没问题了兄弟,记得好好玩明日方舟(原本这里有东西的,但是忘记怎么写了)