0ptsTLEc++
查看原帖
0ptsTLEc++
772909
Lovely_CCCyh___楼主2022/11/11 19:41
#include<bits/stdc++.h>
using namespace std;
bool now;
void solve(string s1,string s2,string s3,int z,int sum)
{
	if(now) return ;
	if(sum>=6*12*8*4){
		return ;
	}
	if(s1=="GGGGGGGGGGGG"&&s2=="RRRRRRRR"&&s3=="YYYY"){
		cout<<"YES"<<endl;
		now=1; 
		return ;
	}
	if(z<12*8*4){
		string ts1=s1,ts2=s2,ts3=s3;
		ts1+=s1[0];ts2+=s2[0];ts3+=s3[0];
		ts1.erase(0,1);ts2.erase(0,1);ts3.erase(0,1);
		solve(ts1,ts2,ts3,z+1,sum+1);
	}
	string ts1=s1,ts2=s2,ts3=s3;
	ts1=s2[0]+ts1;ts2=s3[0]+ts2;ts3=s1[0]+ts3;
	ts1.erase(1,1);ts2.erase(1,1);ts3.erase(1,1);
	solve(ts1,ts2,ts3,0,sum+1);
}
void work()
{
	now=false;
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	solve(s1,s2,s3,0,0);
	if(!now) cout<<"NO"<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	int T;
	cin>>T;
	while(T--) work();
	return 0;
}
2022/11/11 19:41
加载中...