Codeforces1191B. Tokitsukaze and Mahjong模拟

https://codeforces.com/contest/1191/problem/B
按字母相等的个数分类
然后考虑数字差值 0 1 2

#include<bits/stdc++.h>
#include<deque>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define forn(i,n)  for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
 
typedef long long ll;
 
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const ll MOD=998244353; 
const int maxn=2e5+5;
 
int q,k,ans;
 

int main()
{
	vector<string> s(3);
	cin>>s[0]>>s[1]>>s[2];
	sort(s.begin(),s.end());	//按数字递增 
	string a=s[0],b=s[1],c=s[2];
	if(a[1]==b[1] && b[1]==c[1]){	//3个字母相同前提下 
		if(a[0]==b[0] && b[0]==c[0])	//数字也都相同 
			cout<<0<<endl;
		else if(a[0]==b[0] || b[0]==c[0])//二个数字相等 
			cout<<1<<endl;
		else if(a[0]+1==b[0] && b[0]+1==c[0])	//递增 
			cout<<0<<endl;
		else if(a[0]+1==b[0] || b[0]+1==c[0] || a[0]+2==b[0] || b[0]+2==c[0])
			cout<<1<<endl;
		else
			cout<<2<<endl;
	}
	else if(a[1]==b[1]){
		if(a[0]==b[0] || a[0]+1==b[0] || a[0]+2==b[0])
			cout<<1<<endl;
		else
			cout<<2<<endl;
	}
	else if(b[1]==c[1]){
		if(b[0]==c[0] || b[0]+1==c[0] || b[0]+2==c[0])
			cout<<1<<endl;
		else
			cout<<2<<endl;
	}
	else if(a[1]==c[1]){
		if(a[0]==c[0] || a[0]+1==c[0] || a[0]+2==c[0])
			cout<<1<<endl;
		else
			cout<<2<<endl;
	}
	else{	//各一种
		cout<<2<<endl; 
	}
	return 0;
}

/*


*/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值