codeforces 141A Amusing Joke(模拟水题)

迈不过友情╰ 2022-06-05 12:23 330阅读 0赞

So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two “New Year and Christmas Men” meet, thear assistants cut out of cardboard the letters from the guest’s name and the host’s name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters’ names. Then he may have shuffled the letters and put them in one pile in front of the door.

The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.

Help the “New Year and Christmas Men” and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.

Input

The input file consists of three lines: the first line contains the guest’s name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.

Output

Print “YES” without the quotes, if the letters in the pile could be permuted to make the names of the “New Year and Christmas Men”. Otherwise, print “NO” without the quotes.

Example

Input

  1. SANTACLAUS
  2. DEDMOROZ
  3. SANTAMOROZDEDCLAUS

Output

  1. YES

Input

  1. PAPAINOEL
  2. JOULUPUKKI
  3. JOULNAPAOILELUPUKKI

Output

  1. NO

Input

  1. BABBONATALE
  2. FATHERCHRISTMAS
  3. BABCHRISTMASBONATALLEFATHER

Output

  1. NO

Note

In the first sample the letters written in the last line can be used to write the names and there won’t be any extra letters left.

In the second sample letter “P” is missing from the pile and there’s an extra letter “L”.

In the third sample there’s an extra letter “L”.

题解:

一个简单的桶排序计数

代码:

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. #include<queue>
  5. #include<stack>
  6. #include<math.h>
  7. #include<vector>
  8. #include<map>
  9. #include<set>
  10. #include<stdlib.h>
  11. #include<cmath>
  12. #include<string>
  13. #include<algorithm>
  14. #include<iostream>
  15. using namespace std;
  16. int a[30];
  17. int main()
  18. {
  19. int i,j,n;
  20. char s[105];
  21. memset(a,0,sizeof(a));
  22. scanf("%s",s);
  23. for(i=0;s[i];i++)
  24. {
  25. a[s[i]-'A']++;
  26. }
  27. scanf("%s",s);
  28. for(i=0;s[i];i++)
  29. {
  30. a[s[i]-'A']++;
  31. }
  32. scanf("%s",s);
  33. for(i=0;s[i];i++)
  34. {
  35. a[s[i]-'A']--;
  36. }
  37. int tag=1;
  38. for(i=0;i<30;i++)
  39. {
  40. if(a[i]!=0)
  41. tag=0;
  42. }
  43. if(tag)
  44. printf("YES\n");
  45. else
  46. printf("NO\n");
  47. return 0;
  48. }

发表评论

表情:
评论列表 (有 0 条评论,330人围观)

还没有评论,来说两句吧...

相关阅读