QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#794951 | #9549. The Magician | Kogenta2010 | WA | 0ms | 3716kb | C++14 | 1.8kb | 2024-11-30 17:03:47 | 2024-11-30 17:03:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int cnt[4];
int stat[6];
int conv(char k){
if(k=='D')return 0;
else if(k=='C')return 1;
else if(k=='H')return 2;
else if(k=='S')return 3;
else return -1;
}
char se[4]={'D','C','H','S'};
int main(){
int t,n,x,ans,rem;
char a;
cin>>t;
while(t--){
cin>>n;
ans=rem=0;
bool lov=0,dea=0;
for(int i=0;i<4;i++){
cnt[i]=0;
}
a=getchar();
for(int i=1;i<=n;i++){
a=getchar();
while(a==' '){
a=getchar();
}
a=getchar();
cnt[conv(a)]++;
}
for(int i=0;i<4;i++){
ans+=cnt[i]/5;
cnt[i]%=5;
rem+=cnt[i];
}
for(int i=0;i<6;i++){
cin>>stat[i];
}
while(rem>=5){
bool exec=0;
int maxcrd=-1,maxrec=-1;
for(int i=0;i<4;i++){
if(cnt[i]==0)continue;
if(cnt[i]>maxcrd){
maxcrd=cnt[i];
maxrec=i;
}
else if(cnt[i]==maxcrd&&stat[i]==1){
maxrec=i;
}
}
if(maxcrd==4){
if(stat[maxrec]==1||stat[4]==1||stat[5]==1){
ans++;
exec=1;
rem-=5;
if(stat[maxrec]==1){
stat[maxrec]=0;
}
else if(stat[5]==1){
stat[5]=0;
}
else if(stat[4]==1){
stat[4]=0;
}
}
}
else if(maxcrd==3){
if(stat[maxrec]==1||(stat[4]==1&&stat[5]==1)){
ans++;
exec=1;
rem-=5;
if(stat[maxrec]==1){
stat[maxrec]=0;
}
else{
stat[4]=0;
stat[5]=0;
}
}
}
else if(maxcrd==2){
if(stat[maxrec]==1){
stat[maxrec]=0;
ans++;
exec=1;
rem-=5;
}
else if(stat[4]&&stat[5]){
for(int i=0;i<4;i++){
if(stat[i]){
ans++;
exec=1;
rem-=5;
stat[i]=0;
stat[4]=0;
stat[5]=0;
}
}
}
}
if(!exec)break;
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
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
output:
1 1 0 2
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3688kb
input:
13 10 AD 2D 3D 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2D 3D 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2H 3D 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2H 3H 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2H 3H 4H 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AS 2S 3S 4S 5S 6S 7S 8S 9S TS 0 1 0 0 0 0 10 AC 2S 3S 4S 5S 6S 7S 8S ...
output:
2 1 1 2 2 2 1 1 2 2 0 0 0
result:
wrong answer 3rd lines differ - expected: '2', found: '1'