30分求助!(悬一关)
查看原帖
30分求助!(悬一关)
655082
YuTianQwQ楼主2023/6/21 19:03
#include <bits/stdc++.h>
using namespace std;
#define FASTOI ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,ans = 0;
vector<char> cnt[16*2];
int ctn(char k)
{
	if(k == 'T') return 10;
	else if(k == 'J') return 11;
	else if(k == 'Q') return 12;
	else if(k == 'K') return 13;
	else if(k == 'A') return 14;
	else return (int(k)-'0');
}
int ctn2(char k)
{
	if(k == 'S') return 0;
	else if(k == 'H') return 1;
	else if(k == 'C') return 2;
	else if(k == 'D') return 3;
	else return 404;
}
int main()
{
	FASTOI;
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		char t[2];
		cin >> t;
//		cout << ctn(t[1]) << endl;
		cnt[ctn(t[1])].push_back(t[0]);
	}
//	return 0;
	for(int i = 0;i < 16;i++)
	{
		int t[4] = {0,0,0,0};
		for(auto j : cnt[i]) t[ctn2(j)]++;
//		for(auto j : t) cout << j << " ";
		sort(t,t+4);
		int sum = 0;
		for(int j = 0;j < 4;j+=2)
		{
//			cout << j << endl;
			int l = t[j]+t[j+1];
			l/=3;
			sum += l;
		}
		ans += sum;
		//cout << sum << endl;
	}
	cout << ans;
	return 0;
}
/*
0 1 2 3 4 5 6 7 8 9 T J Q K A
*/
2023/6/21 19:03
加载中...