CSU - 1550 Simple String —— 字符串
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550
题解:
1.A+B 与C的交集必须>=n
2.A与C的交集必须>=n/2,B与C的交集必须>=n/2。
代码如下:
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ms(a, b) memset((a), (b), sizeof(a))
typedef long long ll;
const ll mod=1e9+; char a[], b[], c[];
int s1[],s2[],s3[],ss[]; void solve()
{
while(scanf("%s",a)!=EOF)
{
scanf("%s%s",b,c);
int n = strlen(a); ms(s1,); ms(s2,); ms(s3,), ms(ss,);
int m1 = , m2 = , m3 = ;
for(int i = ; i<n; i++)
{
s1[a[i]-]++; ss[a[i]-]++;
s2[b[i]-]++; ss[b[i]-]++;
s3[c[i]-]++;
} for(int i = ; i<; i++)
{
m1 += min(s1[i],s3[i]);
m2 += min(s2[i],s3[i]);
m3 += min(ss[i],s3[i]);
} if(m3<n || m1*<n || m2*<n)
puts("NO");
else
puts("YES");
//cout<<m1<<' '<<m2<<' '<<m3<<endl;
}
} int main()
{
solve();
return ;
}
CSU - 1550 Simple String —— 字符串的更多相关文章
- Water --- CSU 1550: Simple String
Simple String Problem's Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1550 Mean: 略. analy ...
- 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][ ...
- FZU - 2218 Simple String Problem(状压dp)
Simple String Problem Recently, you have found your interest in string theory. Here is an interestin ...
- String 字符串,heredoc,nowdoc
一个字符串可以用 4 种方式表达: 单引号 双引号 heredoc 语法结构 nowdoc 语法结构(自 PHP 5.3.0 起) 单引号 定义一个字符串的最简单的方法是用单引号把它包围起来(字符 ' ...
- Java String字符串/==和equals区别,str。toCharAt(),getBytes,indexOf过滤存在字符,trim()/String与StringBuffer多线程安全/StringBuilder单线程—— 14.0
课程概要 String 字符串 String字符串常用方法 StringBuffer StringBuilder String字符串: 1.实例化String对象 直接赋值 String str=& ...
- [CareerCup] 1.3 Permutation String 字符串的排列
1.3 Given two strings, write a method to decide if one is a permutation of the other. 这道题给定我们两个字符串,让 ...
- 03-Java String字符串详解
1.Java字符串String A.实例化String字符串:直接赋值(更合理一些,使用较多).使用关键字new. B.String内容的比较 // TODO Auto-generated metho ...
随机推荐
- Linux下安装python3.3.2及configrue、make、make install
一.安装python3.3.2 raspberry的/usr/local/src目录没有权限,可执行如下命令 pi@raspberrypi:~$ sudo chmod -R 777 /usr/loca ...
- IIS下安装memcached管理工具—MemAdmin
1.先看这篇文章 http://www.cnblogs.com/joylee/archive/2013/01/07/memadmin.html . 2.在IIS下安装的php-cgi.exe程序版本为 ...
- 百科知识 .e,.ec文件如何打开
1 .e是易语言源文件,你可以从以下网址下载e语言编程环境: http://www.xiazaiba.com/html/409.html 2 安装之后会自动关联.e文件. 3 打开一个e语言文 ...
- iframe截取站点的部分内容
<div style="width:630px;height:350px;overflow:hidden;border:0px"> & ...
- Thrift安装介绍
一.简介 1.语言库要求 因为thrift支持多语言.所以编译thrift源代码的过程中,会用到该语言的一些类库.如c++的boost.java的jdk等. 那么,在安装thrift过程中,须要对各种 ...
- 网页编程-django前传
1.js正则表达式 http://www.cnblogs.com/wupeiqi/articles/5602773.html test - 判断字符串是否符合规定的正则 正则表达式: rep = ...
- 分享一个小工具:Excel表高速转换成JSON字符串
在游戏项目中一般都须要由策划制作大量的游戏内容,当中非常大一部分是使用Excel表来制作的.于是程序就须要把Excel文件转换成程序方便读取的格式. 之前项目使用的Excel表导入工具都是通过Offi ...
- 【重磅干货】看了此文,Oracle SQL优化文章不必再看!
目录 SQL优化的本质 SQL优化Road Map 2.1 制定SQL优化目标 2.2 检查执行计划 2.3 检查统计信息 2.4 检查高效访问结构 2.5 检查影响优化器的参数 2.6 SQL语句编 ...
- PHP中的面向对象 中的类(class)
2.11 上午讲的是面向对象中的类(class),一个非常抽象的概念, 类里面成员的定义有 public$abc; private$abc(私有变量): protect $abc(受保护的变量): 下 ...
- EasyDarwin开源流媒体云平台中boost Base64编解码后与源长度不匹配的bug
本文转自EasyDarwin团队Alex的博客:http://blog.csdn.net/cai6811376 EasyDarwin云平台中部分协议使用了Base64编码昨晚报文通信的载体.比如在对摄 ...