Time Limit: 3000MS | Memory Limit: Unknown | 64bit IO Format: %lld & %llu |
Description



Input
Input file contains several test cases. Each of them consists of two lines. The first line contains the message engraved on the plate. Before encrypting, all spaces and punctuation marks were removed, so the encrypted message contains only capital letters of the English alphabet. The second line contains the original message that is conjectured to be encrypted in the message on the first line. It also contains only capital letters of the English alphabet. The lengths of both lines of the input file are equal and do not exceed 100.
Output
For each test case, print one output line. Output `
YES' if the message on the first line of the input file could be the result of encrypting the message on the second line, or `
NO' in the other case.
Sample Input
JWPUDJSTVP VICTORIOUS MAMA ROME HAHA HEHE AAA AAA NEERCISTHEBEST SECRETMESSAGES
Sample Output
YES NO YES YES NO
Source
分析:
区域赛水题,难得遇到一道这么简单的区域赛题目。
读懂题意就ok了。
ac代码:
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=100+10;
//const int maxm=30;
char a[maxn],b[maxn];
int main()
{
int n,m;
while(scanf("%s%s",a,b)!=EOF)
{
int c[26]={0},d[26]={0};
n=strlen(a);
for(int i=0;i<n;i++)
{
c[a[i]-'A']++;
d[b[i]-'A']++;
}
sort(c,c+26);
sort(d,d+26);
if(memcmp(c,d,sizeof(c)))//c,d相等返回0
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=100+10;
//const int maxm=30;
char a[maxn],b[maxn];
int main()
{
int n,m;
while(scanf("%s%s",a,b)!=EOF)
{
int c[26]={0},d[26]={0};
n=strlen(a);
for(int i=0;i<n;i++)
{
c[a[i]-'A']++;
d[b[i]-'A']++;
}
sort(c,c+26);
sort(d,d+26);
if(memcmp(c,d,sizeof(c)))//c,d相等返回0
printf("NO\n");
else
printf("YES\n");
}
return 0;
}