QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#185707 | #5065. Beautiful String | ykpcx# | RE | 0ms | 0kb | C++17 | 1.8kb | 2023-09-22 15:28:53 | 2023-09-22 15:28:54 |
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
using namespace std;
using ll = long long;
const int N = 55;
int n, m, a[N], b[N], p;
int read() {
string x;
cin >> x;
int ret;
if ('2' <= x[0] && x[0] <= '9') ret = x[0] - '0';
else if (x[0] == 'T') ret = 10;
else if (x[0] == 'J') ret = 11;
else if (x[0] == 'Q') ret = 12;
else if (x[0] == 'K') ret = 13;
else if (x[0] == 'A') ret = 14;
return ret;
}
bool solve() {
cin >> n >> m;
for (int i = 0; i < n; i++) a[i] = read();
for (int j = 0; j < m; j++) b[j] = read();
p = read();
if (n == 1) return false;
int bmax = *max_element(b, b + m);
int amax = *max_element(a, a + n);
int alc = 0;
int mal = -1;
int blc = 0;
int mbl = -1;
for (int i = 0; i < n; i++) {
if (a[i] < p) {
alc++;
mal = max(mal, a[i]);
}
}
for (int i = 0; i < m; i++) {
if (b[i] < p) {
blc++;
mbl = max(mbl, b[i]);
}
}
if (n == 2) {
if (alc == 0) return false;
if (m == 1) {
return b[0] <= mal;
}
if (bmax <= mal) return true;
// if (bmax)
// sort(b, b + m);
// auto ptr = upper_bound(b, b + m, mal);
// if (*ptr < p) blc--;
// int bgec = m - blc;
// bgec--;
// printf("blc = %d\n", blc);
return blc > 1;
}
// if (n == 3) {
// }
if (blc == 0) {
return false;
} else if (blc == 1) {
if (n == 3) return false;
if (m == 1) return mal >= mbl; //
return amax > bmax && alc >= 2 && mal >= mbl;
} else if (blc >= 2) {
return alc != 0;
}
// printf("%lld\n", ans);
return false;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int t; cin >> t; while (t--)
printf("%s\n", solve() ? "Pang" : "Shou");
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
2 114514 0000000