Time Limit: 1 Sec Memory Limit: 256 Mb Submitted: 682 Solved: 287
Description
Welcome,this is the 2015 3th Multiple Universities Programming Contest ,Changsha ,Hunan Province. In order to let you feel fun, ACgege will give you a simple problem. But is that true? OK, let’s enjoy it.
There are three strings A , B and C. The length of the string A is 2*N, and the length of the string B and C is same to A. You can take N characters from A and take N characters from B. Can you set them to C ?
Input
There are several test cases.
Each test case contains three lines A,B,C. They only contain upper case letter. 0<N<100000 The input will finish with the end of file.
Output
For each the case, if you can get C, please print “YES”. If you cann’t get C, please print “NO”.
Sample Input
AABBBBCCAACCAAAABBBBAAAA
Sample Output
YESNO
Hint
Source
题目意思: 给你三个字符串 a,b,c 长度都是2*n 问你从a和b中各抽出n给字符 能不能组成c
分析: 统计a,b,c中26个字符出现的次数 如果某字符在a中出现次数+在b中出现次数小于该字符在c中出现次数 那么肯定不能组成c 1.A+B 与C的交集必须>=n 2.A与C的交集必须>=n/2,B与C的交集必须>=n/2。 理解上面两句话就可以了
#include#include #include #include #include #include #include #include #include #include #include #include