Simple String

Problem's Link:   http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1550


Mean:

略。

analyse:

水题。

Time complexity: O(n)

Source code: 

//  Memory   Time
// 1347K 0MS
// by : crazyacking
// 2015-03-29-12.08
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define MAXN 1000010
#define LL long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie();
// freopen("C:\\Users\\Devin\\Desktop\\cin.cpp","r",stdin);
// freopen("C:\\Users\\Devin\\Desktop\\cout.cpp","w",stdout);
string a,b,c;
while(cin>>a>>b>>c)
{
bool flag=true;
int len=a.length();
int aa[],bb[],cc[],dd[];
memset(aa,,sizeof aa),memset(bb,,sizeof bb),memset(cc,,sizeof cc),memset(dd,,sizeof dd);
for(int i=;i<len;++i)
{
aa[a[i]-'A']++;
bb[b[i]-'A']++;
cc[c[i]-'A']++;
}
for(int i=;i<;++i)
{
if(aa[i]+bb[i]<cc[i])
{
flag=false;
puts("NO");
break;
}
}
if(!flag) continue;
for(int i=;i<;++i)
{
dd[i]=cc[i]-aa[i];
}
int sum=;
for(int i=;i<;++i)
{
if(dd[i]>)
{
sum+=dd[i];
if(dd[i]>bb[i])
{
flag=false;
break;
}
} }
if(!flag)
{
puts("NO");
continue;
}
int half=len/;
sum=;
for(int i=;i<;++i)
{
if(dd[i]<=)
{
sum+=min(bb[i],cc[i]);
}
else
{
sum+=min(bb[i],cc[i]);
}
}
if(sum>=half)
{
puts("YES");
continue;
}
else
{
puts("NO");
continue;
}
}
return ;
}
/* */
/**************************************************************
Problem: 1550
User: crazyacking
Language: C++
Result: Accepted
Time:8 ms
Memory:1976 kb
****************************************************************/

 

Water --- CSU 1550: Simple String的更多相关文章

  1. CSU - 1550 Simple String —— 字符串

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 题解: 1.A+B 与C的交集必须>=n 2.A与C的交集必须>= ...

  2. 1550: Simple String (做得少的思维题,两个字符串能否组成另外一个字符串问题)

    1550: Simple String Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Submitt ...

  3. 1550: Simple String 最大流解法

    http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 很久以前做的一题,当时队友用最大流做,现在我也是 这个转化为二分图多重匹配,就是一样的意 ...

  4. csu 1550(字符串处理思路题)

    1550: Simple String Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 481  Solved: 211[Submit][Status][ ...

  5. (比赛)A - Simple String Problem

    A - Simple String Problem Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%lld & ...

  6. FZU - 2218 Simple String Problem(状压dp)

    Simple String Problem Recently, you have found your interest in string theory. Here is an interestin ...

  7. D - Simple String CSU - 1550

    http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 很久都没补这题,最近想学网络流,就看看,队友以前用网络流过的,Orz, 但是这题只需要简 ...

  8. FZU 2218 Simple String Problem(简单字符串问题)

    Description 题目描述 Recently, you have found your interest in string theory. Here is an interesting que ...

  9. csu oj 1341 string and arrays

    Description 有一个N*N的字符矩阵,从上到下依次记为第1行,第2行,……,第N行,从左至右依次记为第1列,第2列,……,第N列. 对于这个矩阵会进行一系列操作,但这些操作只有两类: (1) ...

随机推荐

  1. 初探单点登录 SSO

    单点登录 单点登录(Single sign-on,SSO)是一种访问控制,在多个软件应用中,用户只需登录其中一个应用,就可以成功访问其他应用:同样,用户只需注销其中一个应用,就可以成功注销其他应用. ...

  2. jQuery Mobile 移动开发中的日期插件Mobiscroll使用说明

    近期在移动方面的开发,使用jQuery Mobile ,移动方面的插件不如Web 方面的插件多,选择的更少,有一些需要自己去封装,但功力尚不足啊. 日期插件JQM也提供了内置的,但样式方面不好看,只好 ...

  3. Aspose转PDF时乱码问题的解决

    主要原因是服务器上一般安装的字体都是有限的,而我们日常生活工作中总是喜欢用一些比较特别的字体,比如宋体GB2312,这时候如果用Aspose转PDF就会出现乱码,解决方法也比较简单,把本地的特殊字体拷 ...

  4. mvc edmx 的config文件

    <?xml version="1.0" encoding="utf-8"?> <configuration> <connectio ...

  5. python use dom to write xml file

    #encoding:utf-8 ''' write xml in dom style ''' from xml.dom.minidom import Document doc = Document() ...

  6. Customer IEnuramble Extension

    public static class IEnurambleExtension { public static IEnumerable<TSource> DistinctBy<TSo ...

  7. iOS:缓存与Operation优先级问题

    这篇博客来源于今年的一个面试题,当我们使用SDWebImgae框架中的sd_setImageWithURL: placeholderImage:方法在tableView或者collectionView ...

  8. Python中的模块与包

    标准库的安装路径 在import模块的时候,python是通过系统路径找到这些模块的,我们可以将这些路径打印出来: >>> pprint.pprint(sys.path) ['', ...

  9. linux ss 网络状态工具

    ss是Socket Statistics的缩写 查看网络状态,经常用的命令:  watch ss -lnt ss命令用于显示socket状态. 他可以显示PACKET sockets, TCP soc ...

  10. asp.net首页设置

    在web.config中设置首页 <configuration> <system.web> <compilation debug="true" tar ...