#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#define ms(x,y) memset(x,y,sizeof(x))
const int MAXN=1000+10;
const int INF=1<<30;
using namespace std;
char a[8][6];
char name[][10]={"颜色","食物","地方","饮料","香烟","宠物","房号"};
char Color[][10]={"","红","黄","蓝","绿","白"};
char Food[][10]={"","萨饼","鸡肉","面条","牛肉","豆腐"};
char From[][10]={"","北京","上海","天津","成都","香港"};
char Drink[][10]={"","矿泉水","茅台","啤酒","茶","葡萄酒"};
char Cigar[][10]={"","希尔顿","万宝路","555","红塔山","健牌"};
char Pet[][10]={"","马","蛇","鱼","猫","狗"};
char *ptr;
//假设
/*num 1 2 3 4 5
color 红 黄 蓝 绿 白
food 萨饼 鸡肉 面 牛肉 豆腐
from 北京 上海 天津 成都 香港
drink 矿泉水 茅台 啤酒 茶 葡萄酒
烟 希尔顿 万宝路 555 红塔山 健牌
pet 马 蛇 鱼 猫 狗
*/
bool J1()
{
int red,blue,white;
ptr=strchr(a[0], '1');
red=ptr-a[0];
ptr=strchr(a[0], '3');
blue=ptr-a[0];
ptr=strchr(a[0], '5');
white=ptr-a[0];
if(red>blue && red<white) return 1;
return 0;
}
bool J2()
{
int yellow;
ptr=strchr(a[0], '2');
yellow=ptr-a[0];
char from=a[2][yellow];
if(from=='5' && yellow!=0) return 1;
return 0;
}
bool J3()
{
int num1,num2;
ptr=strchr(a[1], '1');
num1=ptr-a[1];
ptr=strchr(a[3], '1');
num2=ptr-a[3];
if(abs(num2-num1)==1) return 1;
return 0;
}
bool J4()
{
int num1,num2;
char d;
ptr=strchr(a[2],'1');
d=a[3][ptr-a[2]];
num1=ptr-a[2];
ptr=strchr(a[2],'2');
num2=ptr-a[2];
if(d=='2' && abs(num1-num2)==1) return 1;
return 0;
}
bool J5()
{
int num1,num2;
ptr=strchr(a[4],'1');
num1=ptr-a[4];
ptr=strchr(a[5],'1');
num2=ptr-a[5];
if(num1-num2==1) return 1;
return 0;
}
bool J6()
{
char food;
ptr=strchr(a[3],'3');
food=a[1][ptr-a[3]];
if(food=='2') return 1;
return 0;
}
bool J7()
{
char pet;
ptr=strchr(a[0],'4');
pet=a[5][ptr-a[0]];
if(pet=='5') return 1;
return 0;
}
bool J8()
{
char pet;
int num1,num2;
ptr=strchr(a[1],'3');
num1=ptr-a[1];
ptr=strchr(a[5],'2');
num2=ptr-a[5];
if(abs(num1-num2)==1) return 1;
return 0;
}
bool J9()
{
char food,from;
int num,num1,num2;
ptr=strchr(a[2],'3');
num=ptr-a[2];
int x=num-1;
int y=num+1;
if(x<0 || y>=5) return 0;
if(a[1][x]=='4' && a[2][y]=='4') return 1;
return 0;
}
bool J10()
{
int num;
ptr=strchr(a[5],'3');
num=ptr-a[5];
if(num==4) return 1;
return 0;
}
bool J11()
{
int num,num1,num2;
ptr=strchr(a[4],'2');
num=ptr-a[4];
ptr=strchr(a[4],'1');
num1=ptr-a[4];
ptr=strchr(a[4],'3');
num2=ptr-a[4];
if(abs(num-num1)==1 && abs(num2-num)==1) return 1;
return 0;
}
bool J12()
{
char drink;
ptr=strchr(a[0],'1');
drink=a[3][ptr-a[0]];
if(drink=='4') return 1;
return 0;
}
bool J13()
{
int num1,num2;
ptr=strchr(a[3],'5');
num1=ptr-a[3];
ptr=strchr(a[1],'5');
num2=ptr-a[1];
if(num1-num2==1) return 1;
return 0;
}
bool J14()
{
int num,num1,num2;
ptr=strchr(a[4],'4');
num=ptr-a[4];
ptr=strchr(a[4],'5');
num1=ptr-a[4];
ptr=strchr(a[2],'2');
num2=ptr-a[2];
if(abs(num-num1)>1 && abs(num-num2)>1) return 1;
return 0;
}
bool J15()
{
int num;
ptr=strchr(a[2],'2');
num=ptr-a[2];
if(num==1) return 1;
return 0;
}
bool J16()
{
int num;
ptr=strchr(a[3],'1');
num=ptr-a[3];
if(num==2) return 1;
return 0;
}
bool J17()
{
char drink;
ptr=strchr(a[1],'3');
drink=a[3][ptr-a[1]];
if(drink=='5') return 1;
return 0;
}
bool J18()
{
int num1,num2;
ptr=strchr(a[4],'3');
num1=ptr-a[4];
ptr=strchr(a[4],'1');
num2=ptr-a[4];
if(num1-num2>0) return 1;
return 0;
}
bool judge()
{
if(J1() && J2() && J3() && J4() && J5() && J6() && J7() && J8() && J9() && J10() && J11() && J12() && J13() && J14() && J15() && J16() && J17() && J18()) return 1;
return 0;
}
void dfs(int cnt)
{
//这里一堆剪枝~(之前不加
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠