对于第三种情况:就是要让这13种牌的数量不等于0,而且其他牌的数量为0;
#include
#include
#include
#include
#include
using namespace std;
int T, ans[300], sub, p[100], v[100];
char c, str[10];
const char * mah[] =
{
"1m","2m","3m","4m","5m","6m","7m","8m","9m",
"1s","2s","3s","4s","5s","6s","7s","8s","9s",
"1p","2p","3p","4p","5p","6p","7p","8p","9p",
"1c","2c","3c","4c","5c","6c","7c"
};
int ver[20] = {
0,8,9,17,18,26,27,28,29,30,31,32,33
};
int convert(char * s){
for(int i = 0; i < 34; i ++){
if(strcmp(s,mah[i]) == 0)
return i;
}return -1;
}
// return false
bool three(int x){
int ret = 0;
int tmp[35] ;
for(int i = 0; i < 34; i ++) tmp[i] = p[i];
for(int i = 0; i <= 18; i += 9){
for(int j = 0; j < 9; j ++){
if(tmp[i + j] >= 3){
tmp[i + j] -= 3;
ret ++;
}
while(j + 2 < 9 && tmp[i + j] && tmp[i + j + 1] && tmp[i + j + 2]){
tmp[i + j] --;
tmp[i + j + 1] --;
tmp[i + j + 2] --;
ret ++;
}
}
}
for(int j = 0; j < 7; j ++){
if(tmp [27 + j] >= 3){
tmp[27 + j] -= 3;
ret ++;
}
}
if(ret == 4) return true;
return false;
}
bool realcheck(){
for(int i = 0; i < 34; i ++){
if(p[i] >= 2){
p[i] -= 2;
if(three(0)){
p[i] += 2;
return true;
}p[i] += 2;
}
}
return false;
}
bool eyes(){
for(int i = 0; i < 34; i ++){
if(p[i] != 2 && p[i] != 0)
return false;
}
return true;
}
bool spe(){
for(int j = 0; j < 7; j ++)
if(p[j + 27] == 0)
return false;
for(int i = 0; i <= 18; i += 9){
if(p[i] == 0 || p[i + 8] == 0) return false;
for(int j = 1; j < 8; j ++){
if(p[i + j] != 0)
return false;
}
}
return true;
}
bool judge(){
if(realcheck() || eyes() || spe()){
return true;
}return false;
}
int main(){
scanf("%d", & T);
while(T --){
for(int i = 0; i < 13; i ++){
scanf("%s", str);
v[i] = convert(str);
}
memset(p, 0, sizeof(p));
for(int i = 0; i < 13; i ++){
p[v[i]] ++;
}
sub = 0;
for(int i = 0; i < 34; i ++){
if(p[i] < 4){
p[i] ++;
if(judge()){
ans[sub ++] = i;
}
p[i] --;
}
}
if(sub >= 1){
printf("%d", sub);
for(int i = 0; i < sub; i ++){
printf(" %s", mah[ans[i]]);
}printf("\n");
}else{
printf("Nooten\n");
}
}
}