QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#1228 | #758741 | #9549. The Magician | Imakf | yzhx | Success! | 2024-11-21 21:37:02 | 2024-11-21 21:37:07 |
詳細信息
Extra Test:
Wrong Answer
time: 0ms
memory: 3596kb
input:
3 35 8C 7C 6C 5C 4C 3C 2C AC 9H 8H 7H 6H 5H 4H 3H 2H AH 9D 8D 7D 6D 5D 4D 3D 2D AD 9S 8S 7S 6S 5S 4S 3S 2S AS 1 1 0 0 0 0 24 2C AC 4H 3H 2H AH 5D 4D 3D 2D AD KS QS JS TS 9S 8S 7S 6S 5S 4S 3S 2S AS 0 0 0 1 0 1 25 AC 6H 5H 4H 3H 2H AH 8D 7D 6D 5D 4D 3D 2D AD TS 9S 8S 7S 6S 5S 4S 3S 2S AS 1 0 1 0 1 1
output:
7 4 5
result:
wrong answer 1st lines differ - expected: '6', found: '7'
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#758741 | #9549. The Magician | yzhx# | WA | 0ms | 3700kb | C++17 | 4.1kb | 2024-11-17 19:32:43 | 2024-11-21 21:38:25 |
answer
#include <bits/stdc++.h>
using namespace std;
#define re
#define ll long long
#define in inline
int n, a[10], b[10], bb[10];
in void add(char c) {
if (c == 'D') a[1]++;
if (c == 'C') a[2]++;
if (c == 'H') a[3]++;
if (c == 'S') a[4]++;
}
int main() {
int T;
cin >> T;
while (T--) {
cin >> n;
// cout << T << endl;
for (int i = 1; i <= 6; ++i) b[i] = a[i] = 0;
for (int i = 1; i <= n; ++i) {
char s[4];
cin >> s + 1;
// cout << i << ": " << s + 1 << endl;
add(s[2]);
}
// cout << "TTT: " << T << endl;
for (int i = 1; i <= 6; ++i) cin >> b[i];
int ans = 0, sum = 0;
for (int i = 1; i <= 4; ++i) {
ans += a[i] / 5;
a[i] %= 5;
sum += a[i];
}
// cout << "TT: " << T << endl;
if (sum >= 15) {
int flag = 0;
for (int i = 1; i <= 4 && !flag; ++i) // use a[i] translate to other card
{
int t = a[i], fff = 1;
for (int k = 1; k <= 6; ++k) bb[k] = b[k];
for (int j = 1; j <= 4; ++j) {
if (i == j) continue;
int u = 5 - a[j];
if (bb[j]) {
if (t - u < 0) {
fff = 0;
break;
}
t -= u;
u = 0;
continue;
}
if (u && bb[5] && t) {
u--;
t--;
bb[5] = 0;
}
if (u && bb[6] && t) {
u--;
t--;
bb[6] = 0;
}
if (u != 0) {
flag = 1;
break;
}
}
flag |= fff;
}
if (flag == 1) {
cout << ans + 3 << endl;
continue;
}
}
if (sum >= 10) {
int flag = 0;
for (int i = 1; i <= 3; ++i)
for (int j = i + 1; j <= 4; ++j) {
for (int k = 1; k <= 6; ++k) bb[k] = b[k];
int lst = 0, u1 = 5 - a[i], u2 = 5 - a[j];
for (int t = 1; t <= 4; ++t)
if (t != i && t != j) lst += a[t];
if (b[i]) {
int used1 = min(3, min(lst, u1));
lst -= used1;
u1 -= used1;
}
if (b[j]) {
int used1 = min(3, min(lst, u2));
lst -= used1;
u2 -= used1;
}
if (u1 + u2 <= b[5] + b[6]) flag = 1;
if (flag == 1) break;
}
if (flag == 1) {
cout << ans + 2 << endl;
continue;
}
}
// cout << "T: " << T << endl;
if (sum >= 5) {
int flag = 0;
for (int i = 1; i <= 4 && !flag; ++i) {
if (b[i]) {
if (a[i] + b[5] + b[6] >= 2) {
flag = 1;
break;
}
} else {
if (a[i] <= 2) continue;
if (a[i] + b[5] + b[6] >= 5) {
flag = 1;
break;
}
}
}
// cout << T << ' ' << flag << endl;
if (flag == 1) {
cout << ans + 1 << endl;
continue;
}
}
cout << ans << endl;
}
}
/*
4
5
2H 3H 4H 5H 6D
1 1 1 1 0 0
5
2S 3S 4D 5C 6D
0 0 1 0 1 1
5
2S 3S 4D 5C 6D
0 0 1 0 1 0
13
AS 2S 3S 4S 5H 6H 7H 8H 9H TH JH QH KH
0 0 0 0 0 1
*/