QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#1225 | #766694 | #9549. The Magician | Imakf | ruoye123456 | Success! | 2024-11-21 19:12:29 | 2024-11-21 19:12:29 |
详细
Extra Test:
Wrong Answer
time: 0ms
memory: 3788kb
input:
1 30 7C 6C 5C 4C 3C 2C AC 7H 6H 5H 4H 3H 2H AH 7D 6D 5D 4D 3D 2D AD 9S 8S 7S 6S 5S 4S 3S 2S AS 0 0 0 1 1 1
output:
6
result:
wrong answer 1st lines differ - expected: '5', found: '6'
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#766694 | #9549. The Magician | ruoye123456 | WA | 0ms | 3856kb | C++20 | 2.4kb | 2024-11-20 18:16:07 | 2024-11-21 19:14:19 |
answer
#include<bits/stdc++.h>
#define PII pair<int,int>
#define ll long long
#define x first
#define y second
using namespace std;
int color[4];
map<char,int> mp;
// D(方块)、C(梅花)、H(红桃)或 S(黑桃),
int all, x;
void solve()
{
int n;
cin>>n;
x++;
for(int i=0;i<4;++i) color[i] = 0;
mp['D'] = 0, mp['C'] = 1, mp['H'] = 2, mp['S'] = 3;
vector<int> tolor(6);
for(int i=1;i<=n;++i)
{
string a;
cin>>a;
color[mp[a[1]]] ++;
}
//for(int i=0;i<4;++i) cout<<color[i]<<" \n"[i==3];
for(int i=0;i<6;++i) cin>>tolor[i];
int wild = tolor[4] + tolor[5];
int res = 0;
for(int i=0;i<4;++i) res += color[i]/5, color[i] %= 5;
for(int round = 0; round < 4; ++round)
{
int maxn = -1, flag = -1;
for(int i=0;i<4;++i) if(tolor[i] && color[i] > maxn) maxn = color[i], flag = i;
PII t[4];
if(flag == -1) break;
for(int i=0;i<4;++i) t[i].x = color[i], t[i].y = i;
sort(t, t + 4,[&](PII A, PII B) {if(tolor[A.y] != tolor[B.y]){return tolor[A.y]==0;}return A.x < B.x;});
int num = 0;
for(int i=0;i<4;++i)
{
if(!t[i].x || t[i].y == flag||!maxn && t[i].x==4) continue;
if(num < 3 && color[flag]< 5)
{
int tmp = min({3 - num, t[i].x, 5 - color[flag]});
num += tmp;
color[t[i].y] -= tmp;
color[flag] += tmp;
// cout<<t[i].y<<' '<<tmp<<'\n';
}
if(color[flag] == 5) break;
}
//cout<<flag<<' '<<color[flag]<<'\n';
if(color[flag] < 5) break;
color[flag] = 0, res ++;
}
PII t[4];
for(int i=0;i<4;++i) t[i].x = color[i], t[i].y = i;
sort(t, t + 4, [&](PII A, PII B) {return A.x > B.x;});
if(!wild) cout<<res<<'\n';
else if(wild == 1)
{
if(t[0].x == 4 && t[1].x) cout<<res+1<<'\n';
else cout<<res<<'\n';
}
else
{
if(t[0].x == 4 && t[1].x == 4 && (t[2].x + t[3].x >= 2)) cout<<res + 2<<'\n';
else if((t[0].x == 3 || t[0].x == 4) && (t[1].x + t[2].x + t[3].x >= 5 - t[0].x)) cout<<res + 1<<'\n';
else cout<<res<<'\n';
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin>>T;
all = T;
while(T--)
{
solve();
}
return 0;
}