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 n students took part in the exam. The teacher gave them 3 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 100 and the lengths of my students' answers are less than or equal to 600
- 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 2 hours to complete this.
Input
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 n (0 ≤ n ≤ 1000), the number of students.
Next n 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.
Output
For each student write in a different line. Print "WA" if his answer is wrong or "ACC" if his answer is OK.
Examples
Input
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_WonderfulOutput
ACC ACC ACC WA ACC ACC WAInput
Shapur;; is___ a_genius 3 Shapur__a_is___geniUs is___shapur___a__Genius; Shapur;;is;;a;;geni;;us;;Output
WA ACC ACC
测试的时候思路想错了,以为直接看第一个字母进入某个单词判断即可,但是最后7次后发现首字母可以相同;
其实最开始有想法,直接把3个单词6种排序写出来便好,觉得太复杂,懒得写,后来写出来觉得还行
就是3个单词6种排序写出来,并且所有单词包括后来输入测试的都做一个初始化,把大写变成小写,没用的撤了,
还有vis的strcat过不了,研究strcat_s神坑了我半天,strcat_s的第一个参数应是strcat_s(des,strlen(des)+strlen(num)+1,num);
#include<iostream>
#include<cstring>
#include<algorithm>
#include"stdio.h"
#include <stdlib.h> // malloc()
#include <string.h> // strcat_s() && strlen()
using namespace std;
const int N = 100005;
struct node
{
char name[1000];
}p[8];
char a[800], b[800], c[800];
void dele(char a[ ])
{
char ne[800];
int k = 0,j;
memset(ne, 0, sizeof(ne));
for (j = 0; a[j] != '\0'; j++) {
if (a[j] == '-' ||a[j] == ';' || a[j] == '_') {
continue;
}
else if(a[j]>='A'&&a[j]<='Z'){
a[j] = a[j] + 32;
}
ne[k] = a[j];
k++;
}
strcpy_s(a,strlen(ne)+1,ne);
}
void Init()
{
int x;
dele(a);
dele(b);
dele(c);
memset(p[0].name, 0, sizeof(p[0].name));
strcpy_s(p[0].name, a);
x = strlen(p[0].name) + strlen(b) + 1;
strcat_s(p[0].name, x, b);
x = strlen(p[0].name) + strlen(c) + 1;
strcat_s(p[0].name, x, c);
strcpy_s(p[1].name, a);
strcat_s(p[1].name, strlen(c) + strlen(p[1].name) + 1, c);
strcat_s(p[1].name, strlen(b)+strlen(p[1].name) + 1, b);
strcpy_s(p[2].name, b);
strcat_s(p[2].name, strlen(a)+strlen(p[2].name) + 1, a);
strcat_s(p[2].name, strlen(c)+strlen(p[2].name) + 1, c);
strcpy_s(p[3].name, b);
strcat_s(p[3].name, strlen(c)+strlen(p[3].name) + 1, c);
strcat_s(p[3].name, strlen(a)+strlen(p[3].name) + 1, a);
strcpy_s(p[4].name, c);
strcat_s(p[4].name, strlen(b)+strlen(p[4].name) + 1, b);
strcat_s(p[4].name, strlen(a)+strlen(p[4].name) + 1, a);
strcpy_s(p[5].name, c);
strcat_s(p[5].name, strlen(a)+strlen(p[5].name) + 1, a);
strcat_s(p[5].name, strlen(b)+strlen(p[5].name) + 1, b);
}
int main()
{
char alp[800];
int n, i, j, k,flag=0;
cin >> a >> b >> c;
Init();
cin >> n;
for (i = 0; i < n; i++) {
memset(alp, 0, sizeof(alp));
cin >> alp;
flag = 0;
dele(alp);
for (j = 0; j < 6; j++) {
if (strcmp(alp, p[j].name) == 0) {
flag = 1;
break;
}
}
if (flag == 1) {
cout << "ACC" << endl;
}
else {
cout << "WA"<<endl;
}
}
return 0;
}
突然发现应该写个函数stract,每次写好长好烦
还是觉得我的做法挺水的,不过ac很快哈哈,这个做法很容易写,一次AC