codeforces 141A Amusing Joke(模拟水题)
来源:互联网 发布:unity3d 美女 模型 编辑:程序博客网 时间:2024/06/07 18:06
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.
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.
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.
SANTACLAUSDEDMOROZSANTAMOROZDEDCLAUS
YES
PAPAINOELJOULUPUKKIJOULNAPAOILELUPUKKI
NO
BABBONATALEFATHERCHRISTMASBABCHRISTMASBONATALLEFATHER
NO
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".
题解:
一个简单的桶排序计数
代码:
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<math.h>#include<vector>#include<map>#include<set>#include<stdlib.h>#include<cmath>#include<string>#include<algorithm>#include<iostream>using namespace std;int a[30];int main(){ int i,j,n; char s[105]; memset(a,0,sizeof(a)); scanf("%s",s); for(i=0;s[i];i++) { a[s[i]-'A']++; } scanf("%s",s); for(i=0;s[i];i++) { a[s[i]-'A']++; } scanf("%s",s); for(i=0;s[i];i++) { a[s[i]-'A']--; } int tag=1; for(i=0;i<30;i++) { if(a[i]!=0) tag=0; } if(tag) printf("YES\n"); else printf("NO\n"); return 0;}
- codeforces 141A Amusing Joke(模拟水题)
- CodeForces - 141A Amusing Joke (模拟)水
- 141A - Amusing Joke
- codeforces——141A——Amusing Joke
- CF:141A.Amusing Joke
- Codeforces Amusing Joke 题解
- Codeforces Amusing Joke
- A. Amusing Joke
- amusing joke
- #101 (div.2) A. Amusing Joke
- G - Amusing Joke
- code forces Amusing Joke
- CodeForces 599B A - Spongebob and Joke
- Codeforces Round #332 (Div. 2)B. Spongebob and Joke(模拟)
- codeforces 96A (字符串模拟水题)
- codeforces 116A Tram(模拟水题)
- Codeforces 631A Interview【模拟水题】
- a joke
- 计算机组成原理——总线的基本概念
- 进制转换专题
- spring mvc 通过字节流返回图像
- Eclipse 快捷键
- Spring Bean生命周期
- codeforces 141A Amusing Joke(模拟水题)
- 私有云落地解决方案之openstack高可用(pike版本)-haproxy
- struts.xml中获得action中的数据
- Mohican_11/27 C语言—类型
- tensorflow variable_scope共享变量
- 一些C++小程序(二)
- 搭建nginx服务器
- 11.22-11.24课堂笔记
- python文件读取方法