https://vjudge.net/problem/UVA-11210
//被水题虐了一上午...
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const char* mahjong[]={"GZH","1T","2T","3T","4T","5T","6T","7T","8T","9T", "1S","2S","3S","4S","5S","6S","7S","8S","9S", "1W","2W","3W","4W","5W","6W","7W","8W","9W", "DONG","NAN","XI","BEI","ZHONG","FA","BAI"}; ],startMahjong[];//last mahjong ]; int ID(char* s){ ;i<=;i++) ) return i; ; } bool dfs(int l){ ) return true; ;i<=;i++){ ){ c[i]-=; )) return true; c[i]+=; } } ;i<=;i++) <=&&i%&&c[i]>=&&c[i+]>=&&c[i+]>=){ --c[i];--c[i+];--c[i+]; )) return true; ++c[i];++c[i+];++c[i+]; } return false; } bool Judge(){ ;i<=;i++){ ){ c[i]-=; )) return true; c[i]+=; } } return false; } int main() { ; ){ ]==; printf("Case %d:",++caseCount); startMahjong[]=ID(input); ;i<=;i++){ scanf("%s",input);startMahjong[i]=ID(input); } ; ;i<=;i++){ memset(c,,sizeof(c)); ;j<=;j++) c[startMahjong[j]]++; ) continue; c[i]++; if(Judge()){ ok=; printf(" %s",mahjong[i]); } c[i]--; } if(!ok) printf(" Not ready"); printf("\n"); } }