水题。
首先是输入,可以用字符串存储,如果发现是数字就调用 stoi() 函数转化成数字,然后放到一个 bool 数组里,注意 A,J,Q,K 需要特判,这里的 A 可以处理成 。
然后打擂刷新答案即可。
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define piii pair<pii, int>
#define pll pair<ll, ll>
#define plll pair<pll, ll>
#define pref static inline
#define fi first
#define se second
using namespace std;
const int MAXN=25;
int t,x;
string s;
bool flag[MAXN];
namespace heffo_hard{
pref bool nums(string s){
for(int i=0;i<s.size();++i){
if(!isdigit(s[i]))return false;
}
return true;
}
pref void solve(){
memset(flag,0,sizeof(flag));
for(int i=1;i<=17;++i){
cin>>s;
if(nums(s)){
if(stoi(s)==2)continue;
flag[stoi(s)]=1;
}else if(s=="A"){
flag[14]=1;
}else if(s=="J"){
flag[11]=1;
}else if(s=="Q"){
flag[12]=1;
}else if(s=="K")flag[13]=1;
}
int ans=0,cnt=0;
for(int i=3;i<=14;++i){
if(!flag[i]){
ans=max(ans,cnt);
cnt=0;
}else cnt++;
}
ans=max(ans,cnt);//最后还要取max
if(ans<5)cout<<0<<endl;
else cout<<ans<<endl;
}
};
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>t;
while(t--)
heffo_hard::solve();
return 0;
}
/*
*/