Water --- CSU 1550: Simple String
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的更多相关文章
- CSU - 1550 Simple String —— 字符串
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 题解: 1.A+B 与C的交集必须>=n 2.A与C的交集必须>= ...
- 1550: Simple String (做得少的思维题,两个字符串能否组成另外一个字符串问题)
1550: Simple String Submit Page Summary Time Limit: 1 Sec Memory Limit: 256 Mb Submitt ...
- 1550: Simple String 最大流解法
http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 很久以前做的一题,当时队友用最大流做,现在我也是 这个转化为二分图多重匹配,就是一样的意 ...
- csu 1550(字符串处理思路题)
1550: Simple String Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 481 Solved: 211[Submit][Status][ ...
- (比赛)A - Simple String Problem
A - Simple String Problem Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%lld & ...
- FZU - 2218 Simple String Problem(状压dp)
Simple String Problem Recently, you have found your interest in string theory. Here is an interestin ...
- D - Simple String CSU - 1550
http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 很久都没补这题,最近想学网络流,就看看,队友以前用网络流过的,Orz, 但是这题只需要简 ...
- FZU 2218 Simple String Problem(简单字符串问题)
Description 题目描述 Recently, you have found your interest in string theory. Here is an interesting que ...
- csu oj 1341 string and arrays
Description 有一个N*N的字符矩阵,从上到下依次记为第1行,第2行,……,第N行,从左至右依次记为第1列,第2列,……,第N列. 对于这个矩阵会进行一系列操作,但这些操作只有两类: (1) ...
随机推荐
- python数据结构之栈、队列的实现
这个在官网中list支持,有实现. 补充一下栈,队列的特性: 1.栈(stacks)是一种只能通过访问其一端来实现数据存储与检索的线性数据结构,具有后进先出(last in first out,LIF ...
- RAID卡
简单的说,RAID是一种把多块独立的物理硬盘按不同方式组合起来形成一个逻辑硬盘,从而提供比单个硬盘有着更高的性能和提供数据冗余的技术. RAID卡一般分为硬RAID卡和软RAID卡两种 ...
- [Unit Testing] AngularJS Unit Testing - Karma
Install Karam: npm install -g karma npm install -g karma-cli Init Karam: karma init First test: 1. A ...
- nohup启动java命令导致dubbo无法注册
没有任何异常,日志和正常注册日志一模一样,但服务就是没注册成功. 解决办法,screen代替nohup命令. screen screen -ls screen -r pid (ctrl + a)+d
- easyui plugin——etreegrid:CRUD Treegrid
昨天写了一个ko+easyui的同样的实现,感觉写的太乱,用起来十分麻烦,于是今天照着edatagrid,写了一个etreegrid,这样再用ko绑定就方便多了. 使用很简单,$(tableId).e ...
- android自定义view仿照MIUI中音量控制效果
先看效果图: 这就是miui中的音量效果图,实现思路是自定义视图,绘制圆环,然后设置进度显示. 核心代码在onDraw中实现如下: @Override protected void onDraw(Ca ...
- [under the hood]Reduce EXE and DLL Size with LIBCTINY.LIB
Matt Pietrek Download the code for this article: Hood0101.exe (45KB) W ay back in my October 1996 co ...
- ios ZBar扫二维码奇奇怪怪的错误
Undefined symbols for architecture armv7: "_CVPixelBufferGetHeight", referenced from: -[ZB ...
- php的单例模式
据说,单例模式是设计模式中最简单的一种. 不多说,先上代码,然后解说,一共两个文件: danli.class <?php class Danli { //保存类的实例的静态成员变量 static ...
- [转]Android开发最佳实践
——欢迎转载,请注明出处 http://blog.csdn.net/asce1885 ,未经本人同意请勿用于商业用途,谢谢—— 原文链接:https://github.com/futurice/and ...