我是靠谱客的博主 酷酷小蝴蝶,最近开发中收集的这篇文章主要介绍2018ccpc 秦皇岛color(字符串暴力匹配),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

#include<bits/stdc++.h> 
#define ll long long
#define fo(i,j,n) for(register int i=j; i<=n; ++i)
using namespace std;
string S[36]= {
	"aliceisbluebobisgreenyazidisred",
	"aliceisbluebobisredyazidisgreen",
	"aliceisgreenbobisblueyazidisred",
	"aliceisgreenbobisredyazidisblue",
	"aliceisredbobisblueyazidisgreen",
	"aliceisredbobisgreenyazidisblue",	
	"aliceisblueyazidisgreenbobisred",
	"aliceisblueyazidisredbobisgreen",
	"aliceisgreenyazidisbluebobisred",
	"aliceisgreenyazidisredbobisblue",
	"aliceisredyazidisbluebobisgreen",
	"aliceisredyazidisgreenbobisblue",
	"bobisbluealiceisgreenyazidisred",
	"bobisbluealiceisredyazidisgreen",
	"bobisgreenaliceisblueyazidisred",
	"bobisgreenaliceisredyazidisblue",
	"bobisredaliceisblueyazidisgreen",
	"bobisredaliceisgreenyazidisblue",
	"bobisblueyazidisgreenaliceisred",
	"bobisblueyazidisredaliceisgreen",
	"bobisgreenyazidisbluealiceisred",
	"bobisgreenyazidisredaliceisblue",
	"bobisredyazidisbluealiceisgreen",
	"bobisredyazidisgreenaliceisblue",	
	"yazidisbluebobisgreenaliceisred",
	"yazidisbluebobisredaliceisgreen",
	"yazidisgreenbobisbluealiceisred",
	"yazidisgreenbobisredaliceisblue",
	"yazidisredbobisbluealiceisgreen",
	"yazidisredbobisgreenaliceisblue",	
	"yazidisbluealiceisgreenbobisred",
	"yazidisbluealiceisredbobisgreen",
	"yazidisgreenaliceisbluebobisred",
	"yazidisgreenaliceisredbobisblue",
	"yazidisredaliceisbluebobisgreen",
	"yazidisredaliceisgreenbobisblue",
};
char ANS[36][55]= {
	"alice is blue.bob is green.yazid is red.",
	"alice is blue.bob is red.yazid is green.",
	"alice is green.bob is blue.yazid is red.",
	"alice is green.bob is red.yazid is blue.",
	"alice is red.bob is blue.yazid is green.",
	"alice is red.bob is green.yazid is blue.",	
	"alice is blue.yazid is green.bob is red.",
	"alice is blue.yazid is red.bob is green.",
	"alice is green.yazid is blue.bob is red.",
	"alice is green.yazid is red.bob is blue.",
	"alice is red.yazid is blue.bob is green.",
	"alice is red.yazid is green.bob is blue.",
	"bob is blue.alice is green.yazid is red.",
	"bob is blue.alice is red.yazid is green.",
	"bob is green.alice is blue.yazid is red.",
	"bob is green.alice is red.yazid is blue.",
	"bob is red.alice is blue.yazid is green.",
	"bob is red.alice is green.yazid is blue.",
	"bob is blue.yazid is green.alice is red.",
	"bob is blue.yazid is red.alice is green.",
	"bob is green.yazid is blue.alice is red.",
	"bob is green.yazid is red.alice is blue.",
	"bob is red.yazid is blue.alice is green.",
	"bob is red.yazid is green.alice is blue.",	
	"yazid is blue.bob is green.alice is red.",
	"yazid is blue.bob is red.alice is green.",
	"yazid is green.bob is blue.alice is red.",
	"yazid is green.bob is red.alice is blue.",
	"yazid is red.bob is blue.alice is green.",
	"yazid is red.bob is green.alice is blue.",	
	"yazid is blue.alice is green.bob is red.",
	"yazid is blue.alice is red.bob is green.",
	"yazid is green.alice is blue.bob is red.",
	"yazid is green.alice is red.bob is blue.",
	"yazid is red.alice is blue.bob is green.",
	"yazid is red.alice is green.bob is blue.",
};
const string ok = "aliceobyzdslugrnd";
int T;
char s[1005],t[1005],tot;
void pre(){
	tot=0;
	int n=strlen(s);
	for(int i=0; i<n; i++){
		for(int j=0; j<ok.length(); j++){
			if(s[i]==ok[j]){
				t[++tot]=s[i];
				break;
			}
		}
	}
}
bool v1[3],v2[3];
void solve(){
	pre();
	if(tot<31){
		puts("No solution.");
		return;
	}
	for(int i=0; i<36; i++){
		int last=1;
		int j=0;
		for(; j<31; j++){
			for(; last<=tot;){
				if(t[last]==S[i][j]){
					last++;
					break;
				}else last++;
			}
			if(last>tot){
				j++;
				break;
			}
		}
		if(j==31){
			int t='a'-'A';
			bool f=1;
			for(int k=0; k<strlen(ANS[i]); k++){
				if(f){
					putchar(ANS[i][k]-t);
					f=0;
				}else{
					putchar(ANS[i][k]);
					if(ANS[i][k]=='.')f=1;
				}
			}
			putchar(10);
			return;
		}
	}
	puts("No solution.");
}
int main(){
	scanf("%d",&T);
	getchar();
	while(T--){
	//	scanf("%s",s);
		gets(s);
		solve();
	}
	return 0;
}

最后

以上就是酷酷小蝴蝶为你收集整理的2018ccpc 秦皇岛color(字符串暴力匹配)的全部内容,希望文章能够帮你解决2018ccpc 秦皇岛color(字符串暴力匹配)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部