https://codeforces.com/gym/102394/problem/F

【题目大意】

做师哥布置的作业啦

签到题,记录一下状态直接DFS

好久没写题了不出意外地WA了

调了半天发现自己case没break

艹,傻逼错误一定要吸取教训

//This amazing code is written by Primo.Jay.Pan From CUC

//Any questions please contact me
//QQ:898021802
//Mail: primojpan@gmail.com



// Untitled.cpp
// Created by Primo Jay Pan on 2020/8/24.
//While (true) RP++;


//head
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <csignal>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 0x3f3f3f3f
#define maxlongint 2147483647
#define maxint 32767
#define pi(double)acos(-1.0)
#define eps 1e-9
#define MID ((l+r)>>1)
#define lson (o<<1)
#define rson (o<<1|1)
//clear the array
#define cla(a) memset(a,0,sizeof(a))
#define clb(a) memset(a,INF,sizeof(a))
#define clc(a) memset(a,-1,sizeof(a))




using namespace std;


//BIT
inline int lowbit(int x)
{
	return x&(-x);
}

//var
string s;
int a[8];
int vis[8];
bool flag=false;
struct Gym{
	void dfs(int u,int x)
	{
		if (flag)
			return ;
		for (int i=0;i<6;i++)
			{
				if (i==x) continue;
				if (flag) return ;
				if (!vis[i] && ((1<<u)&a[i]))
					{
						if (u==5)
						{
							flag=true;
							printf("Yes\n");
							return ;
						}
						else 
						{
							vis[i]=1;
							dfs(u+1,i);
							vis[i]=0;
						}
					}
				if (flag) return ;
			}
		return ;
	}
	void RunGym()
	{
		memset(a,0,sizeof(a));
		memset(vis,0,sizeof(vis));
		flag=false;
		for (int i=0;i<6;i++)
			{
				s.clear();
				cin>>s;
				int n=s.length();
				for (int j=0;j<n;j++)
				{
					switch(s[j])
					{
						case 'h':
							{
							a[i]|=1;break;}
						case 'a':{
							a[i]|=(1<<1);break;}
						case 'r':{
							a[i]|=(1<<2);break;}
						case 'b':{
							a[i]|=(1<<3);break;}
						case 'i':{
							a[i]|=(1<<4);break;}
						case 'n':{
							a[i]|=(1<<5);	break;}
					}
				}
		
				
			}
		for (int i=0;i<6;i++)
			{
				memset(vis,0,sizeof(vis));
				if (flag) break;
				if ((a[i]&1)==1)
				{
					if (!flag){
						vis[i]=1;
						dfs(1,i);
						vis[i]=0;
					}
				}
			}
		if (!flag)
			printf("No\n");
		return ;
	}	
}work;
//main
int T;
int main()
{
	//freopen("Untitled.cpp.in","r",stdin);
	//freopen("Untitled.cpp.out","w",stdout);
	cin>>T;
	while (T--)
	{
		work.RunGym();
	}
	return 0;
}



/*
Test Data1:
Test Data2:
*/

 


0 条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注