Water --- CSU 1550: Simple String
来源:互联网 发布:linux写入文件命令 编辑:程序博客网 时间:2024/05/16 04:48
Simple StringProblem's Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1550
View Code
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 longusing namespace std;int main(){ ios_base::sync_with_stdio(false); cin.tie(0);// 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[26],bb[26],cc[26],dd[26]; memset(aa,0,sizeof aa),memset(bb,0,sizeof bb),memset(cc,0,sizeof cc),memset(dd,0,sizeof dd); for(int i=0;i<len;++i) { aa[a[i]-'A']++; bb[b[i]-'A']++; cc[c[i]-'A']++; } for(int i=0;i<26;++i) { if(aa[i]+bb[i]<cc[i]) { flag=false; puts("NO"); break; } } if(!flag) continue; for(int i=0;i<26;++i) { dd[i]=cc[i]-aa[i]; } int sum=0; for(int i=0;i<26;++i) { if(dd[i]>0) { sum+=dd[i]; if(dd[i]>bb[i]) { flag=false; break; } } } if(!flag) { puts("NO"); continue; } int half=len/2; sum=0; for(int i=0;i<26;++i) { if(dd[i]<=0) { sum+=min(bb[i],cc[i]); } else { sum+=min(bb[i],cc[i]); } } if(sum>=half) { puts("YES"); continue; } else { puts("NO"); continue; } } return 0;}/**//************************************************************** Problem: 1550 User: crazyacking Language: C++ Result: Accepted Time:8 ms Memory:1976 kb****************************************************************/
0 0
- Water --- CSU 1550: Simple String
- csu 1550: Simple String (字符串)
- CSU 1550-Simple String(字符串)
- ACM--字符串--CSU--1550-- Simple String
- CSU 1010 water drinking
- simple water without reflection
- A simple water problem
- CSU 1080: A simple maze
- Simple Line Editor----CSU 1019
- CSU---D: Simple Line Editor
- HDU4974:A simple water problem
- HDU4974 A simple water problem
- csu oj 1010 Water Drinking(BFS)
- CSU 1320 Scoop water【卡特兰数】
- CSU 1019: Simple Line Editor(模拟)
- CSU 1536 bit string reordering
- 【杂题】 HDOJ 4974 A simple water problem
- HDU - 4974 A simple water problem
- Brute Force
- C++
- 0x3f3f3f3f…编程中无穷大常量的设置技巧
- JAVA
- dp --- CSU 1547: Rectangle
- Water --- CSU 1550: Simple String
- math --- CSU 1554: SG Value
- STL or 线段树 --- CSU 1555: Inversion Sequence
- 快速幂 --- CSU 1556: Jerry's trouble
- 操作系统——进程控制(二)
- 1001. 害死人不偿命的(3n+1)猜想
- STL or Force --- CSU 1553: Good subsequence
- 三分 --- CSU 1548: Design road
- 三分 --- ZOJ 3203 Light Bulb