Hard Work(CF61B)

题目描述

After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer!

Some days before the contest, the teacher took a very simple-looking exam and all his nn students took part in the exam. The teacher gave them 33 strings and asked them to concatenate them. Concatenating strings means to put them in some arbitrary order one after the other. For example from concatenating Alireza and Amir we can get to AlirezaAmir or AmirAlireza depending on the order of concatenation.

Unfortunately enough, the teacher forgot to ask students to concatenate their strings in a pre-defined order so each student did it the way he/she liked.

Now the teacher knows that Shapur is such a fast-calculating genius boy and asks him to correct the students' papers.

Shapur is not good at doing such a time-taking task. He rather likes to finish up with it as soon as possible and take his time to solve 3-SAT in polynomial time. Moreover, the teacher has given some advice that Shapur has to follow. Here's what the teacher said:

  • As I expect you know, the strings I gave to my students (including you) contained only lowercase and uppercase Persian Mikhi-Script letters. These letters are too much like Latin letters, so to make your task much harder I converted all the initial strings and all of the students' answers to Latin.
  • As latin alphabet has much less characters than Mikhi-Script, I added three odd-looking characters to the answers, these include "-", ";" and "_". These characters are my own invention of course! And I call them Signs.
  • The length of all initial strings was less than or equal to 100100 and the lengths of my students' answers are less than or equal to 600600
  • My son, not all students are genius as you are. It is quite possible that they make minor mistakes changing case of some characters. For example they may write ALiReZaAmIR instead of AlirezaAmir. Don't be picky and ignore these mistakes.
  • Those signs which I previously talked to you about are not important. You can ignore them, since many students are in the mood for adding extra signs or forgetting about a sign. So something like Iran;;-- is the same as --;IRAN
  • You should indicate for any of my students if his answer was right or wrong. Do this by writing "WA" for Wrong answer or "ACC" for a correct answer.
  • I should remind you that none of the strings (initial strings or answers) are empty.
  • Finally, do these as soon as possible. You have less than 22 hours to complete this.

输入格式

The first three lines contain a string each. These are the initial strings. They consists only of lowercase and uppercase Latin letters and signs ("-", ";" and "_"). All the initial strings have length from 1 to 100, inclusively.

In the fourth line there is a single integer nn ( 0<=n<=10000<=n<=1000 ), the number of students.

Next nn lines contain a student's answer each. It is guaranteed that the answer meets what the teacher said. Each answer iconsists only of lowercase and uppercase Latin letters and signs ("-", ";" and "_"). Length is from 1 to 600, inclusively.

输出格式

For each student write in a different line. Print "WA" if his answer is wrong or "ACC" if his answer is OK.

题意翻译

前三行给定三个字符串S1S1,S2S2,S3S3。第四行给定一个正整数NN,接下来的NN行,每行一个字符串TiTi。现在要求你的出,在忽略S1S1,S2S2,S3S3及TiTi中的非字母字符后。是否可以通过将S1S1,S2S2,S3S3首尾相连拼接在一起得到TiTi。(忽略大小写)如果可以,输出ACC,否则输出WA

输入输出样例

输入 #1复制

Iran_
Persian;
W_o;n;d;e;r;f;u;l;
7
WonderfulPersianIran
wonderful_PersIAN_IRAN;;_
WONDERFUL___IRAN__PERSIAN__;;
Ira__Persiann__Wonderful
Wonder;;fulPersian___;I;r;a;n;
__________IranPersianWonderful__________
PersianIran_is_Wonderful

输出 #1复制

ACC
ACC
ACC
WA
ACC
ACC
WA

输入 #2复制

Shapur;;
is___
a_genius
3
Shapur__a_is___geniUs
is___shapur___a__Genius;
Shapur;;is;;a;;geni;;us;;

输出 #2复制

WA
ACC
ACC

题解:首先把所有的字符串都转换成小写 利用isupper、islower、tolower快速判断

把前三个字符串按照6种组合方式存到m【】种

对于每个输入的字符串进行比对

#include<iostream>
#include<cstring>
using namespace std;
string a,b,c,a1,b1,c1,m[5],o1;
int main()
{
	int n,flag;
	cin>>a>>b>>c;
	for(int i=0;i<a.length();i++)
	{
		if(a[i]>='a'&&a[i]<='z')
		{
			a1+=a[i];
		 } else if(isupper(a[i]))
		 {
		 	a1+=tolower(a[i]);
		 }
	}
	for(int i=0;i<b.length();i++)
	{
		if(b[i]>='a'&&b[i]<='z')
		{
			b1+=b[i];
		 } else if(isupper(b[i]))
		 {
		 	b1+=tolower(b[i]);
		 }
	}
	for(int i=0;i<c.length();i++)
	{
		if(c[i]>='a'&&c[i]<='z')
		{
			c1+=c[i];
		 } else if(isupper(c[i]))
		 {
		 	c1+=tolower(c[i]);
		 }
	}
	m[0]=a1+b1+c1,m[1]=a1+c1+b1,m[2]=c1+a1+b1,m[3]=c1+b1+a1,m[4]=b1+a1+c1,m[5]=b1+c1+a1;
//	for(int i=0;i<=5;i++)
//	cout<<m[i]<<"*"<<endl;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>o1;
		string t;
		for(int i=0;i<o1.length();i++)
		{
			if(o1[i]>='a'&&o1[i]<='z')
			{
				t+=o1[i];
		 	} 
			 else if(isupper(o1[i]))
		 	{
		 		t+=tolower(o1[i]);
		 	}
		}
		if(t==m[0]||t==m[1]||t==m[2]||t==m[3]||t==m[4]||t==m[5])
		cout<<"ACC\n";
		else cout<<"WA\n";
	}	
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值