Simple String
problem ' s Link:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1550
Mean:
Slightly.
Analyse:
Water problem.
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>#defineMAXN 1000010#defineLL Long Longusing namespacestd;intMain () {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); stringA,b,c; while(cin>>a>>b>>c) {BOOLflag=true; intlen=a.length (); intaa[ -],bb[ -],cc[ -],dd[ -]; memset (AA,0,sizeofAA), memset (BB,0,sizeofBB), memset (CC,0,sizeofCC), memset (DD,0,sizeofDD); for(intI=0; i<len;++i) {Aa[a[i]-'A']++; Bb[b[i]-'A']++; Cc[c[i]-'A']++; } for(intI=0;i< -;++i) {if(aa[i]+bb[i]<Cc[i]) {Flag=false; Puts ("NO"); Break; } } if(!flag)Continue; for(intI=0;i< -;++i) {Dd[i]=cc[i]-Aa[i]; } intsum=0; for(intI=0;i< -;++i) {if(dd[i]>0) {sum+=Dd[i]; if(dd[i]>Bb[i]) {Flag=false; Break; } } } if(!flag) {Puts ("NO"); Continue; } inthalf=len/2; Sum=0; for(intI=0;i< -;++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****************************************************************/
View Code
Water---CSU 1550:simple String