比赛 2012 资格赛 评测结果 A
题目名称 奇怪的语言 最终得分 100
用户昵称 Makazeu 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2012-04-15 15:12:59
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#define get(c) c-'a'
using namespace std;
string tmp,tmp2;
char map[30];

void work()
{
	string::iterator it1=tmp.begin(),it2=tmp2.begin();
	for(;it1!=tmp.end();it1++,it2++) if(*it1!=' ') map[get(*it1)]=*it2;
}
 
int main()
{
	freopen("2012a.in","r",stdin);
	freopen("2012a.out","w",stdout);
	memset(map,' ',sizeof(map));  map[get('q')]='z';  map[get('z')]='q';
	tmp="ejp mysljylc kd kxveddknmc re jsicpdrysi";
	tmp2="our language is impossible to understand"; work();
	tmp.clear();  tmp="rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd";
	tmp2.clear();  tmp2="there are twenty six factorial possibilities"; work();
	tmp.clear();  tmp="de kr kd eoya kw aej tysr re ujdr lkgc jv";
	tmp2.clear(); tmp2="so it is okay if you want to just give up"; work();
	int T;
	scanf("%d\n",&T);
	string::iterator iter;
	bool flag=0; char c;
	for(int i=1;i<=T;i++)
	{
		printf("Case #%d: ",i);tmp.clear();
		getline(cin,tmp);  
		for(iter=tmp.begin();iter!=tmp.end();iter++) 
			if(*iter==' ')
			{
				if(!flag){ printf(" "); flag=1;}
			}
			else 
			{
				c=map[get(*iter)];
				if(c!=' ') {printf("%c",c); flag=0;}
				else if(!flag) printf(" ");
			}
		printf("\n");
	}
	return 0;
}