Codeforces 61B【怪在读题】

搞不懂为什么DFS的写法崩了,然后乱暴力,因为题意不是很懂。。。

主要还是读题吧(很烦

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
const double eps=1e-5;
const double pi=acos(-1.0);
//const int mod=1e9+7;
const int INF=0x3f3f3f3f;

char temp[5][1010];
char tep[30][5030];

bool Judge(char x)
{
    if(x>='a'&&x<='z')
        return 1;
    if(x>='A'&&x<='Z')
        return 1;
    return 0;
}
int num;
void init()
{
    int len,num1;
    char s[1010];
    for(int i=0;i<3;i++)
    {
        scanf("%s",s);
        len=strlen(s);
        num1=0;
        for(int j=0;j<len;j++)
        {
            if(Judge(s[j]))
            {
                if(s[j]>='A'&&s[j]<='Z')
                    temp[i][num1++]=s[j]+'a'-'A';
                else
                    temp[i][num1++]=s[j];
            }
        }
        temp[i][num1]='';
    }
    num=0;
    for(int i=0;i<3;i++)
    {
    	for(int j=0;j<3;j++)
    	{
    		if(i==j) continue;
    		for(int k=0;k<3;k++)
    		{
    			if(j!=k&&k!=i)
    			{
    				int sp=0;
    				int len=strlen(temp[i]);
    				for(int p=0;p<len;p++)
    					tep[num][sp++]=temp[i][p];
    				len=strlen(temp[j]);
    				for(int p=0;p<len;p++)
    					tep[num][sp++]=temp[j][p];
    				len=strlen(temp[k]);
    				for(int p=0;p<len;p++)
    					tep[num][sp++]=temp[k][p];
					tep[num][sp]='';
					num++;
				}
			}
		}
	}
}


int main()
{
    char s[1010],ss[1010];
    int n;
    init();
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",s);
        int len=strlen(s);
        int num1=0;
        for(int j=0;j<len;j++)
        {
                if(Judge(s[j]))
                {
                    if(s[j]>='A'&&s[j]<='Z')
                        ss[num1++]=s[j]+'a'-'A';
                    else
                        ss[num1++]=s[j];
                }
        }
        ss[num1]='';
        int flag=0;
        for(int k=0;k<num;k++)
        {
        	if(strcmp(ss,tep[k])==0)
        	{
        		flag=1;
        		break;
			}
		}
        if(flag)
            puts("ACC");
        else
            puts("WA");
    }
    return 0;
}

/*
aa
aaa
z
1
aaazaa
*/


原文地址:https://www.cnblogs.com/keyboarder-zsq/p/6777513.html