D - Simple String CSU - 1550
http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550
很久都没补这题,最近想学网络流,就看看,队友以前用网络流过的,Orz,
但是这题只需要简单的判断,可能想起来有点麻烦。
考虑一定要从A串取出n个,B串也一定要取出n个,那么A和C的交集一定要大于等于n,同理B。
同时为了得到C串,还需要A + B和C的交集一定要大于等于n * 2
怎么说呢。可以画个图表示下,反正找不到反例。就先码一波。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
const int maxn = ;
char str[maxn], sub1[maxn], sub2[maxn];
int hasStr[], hasSub1[], hasSub2[];
void work() {
int lenstr = strlen(str + );
memset(hasStr, , sizeof hasStr);
memset(hasSub1, , sizeof hasSub1);
memset(hasSub2, , sizeof hasSub2);
for (int i = ; i <= lenstr; ++i) hasStr[str[i]]++;
for (int i = ; i <= lenstr; ++i) hasSub1[sub1[i]]++;
for (int i = ; i <= lenstr; ++i) hasSub2[sub2[i]]++;
int ans1 = , ans2 = , ans3 = ;
for (int i = 'A'; i <= 'Z'; ++i) {
ans1 += min(hasStr[i], hasSub1[i]);
ans2 += min(hasStr[i], hasSub2[i]);
ans3 += min(hasStr[i], hasSub1[i] + hasSub2[i]);
}
if (ans1 < lenstr / || ans2 < lenstr / || ans3 < lenstr) {
printf("NO\n");
} else printf("YES\n");
} int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
while (scanf("%s%s%s", sub1 + , sub2 + , str + ) > ) work();
return ;
}
D - Simple String CSU - 1550的更多相关文章
- 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 ...
- 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 ...
- 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 最大流解法
http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 很久以前做的一题,当时队友用最大流做,现在我也是 这个转化为二分图多重匹配,就是一样的意 ...
- FZU 2218 Simple String Problem(简单字符串问题)
Description 题目描述 Recently, you have found your interest in string theory. Here is an interesting que ...
- FZU - 2218 Simple String Problem 状压dp
FZU - 2218Simple String Problem 题目大意:给一个长度为n含有k个不同字母的串,从中挑选出两个连续的子串,要求两个子串中含有不同的字符,问这样的两个子串长度乘积最大是多少 ...
随机推荐
- 机器视觉 之 Gabor Feature
在机器视觉中,gabor feature是一种比较常见的特征,因为其可以很好地模拟人类的视觉冲击响应而被广泛应用于图像处理, gabor feature 一般是通过对图像与gabor filter做卷 ...
- Can't load AMD 64-bit .dll on a IA 32-bit platform错误
将tomcat的bin目录下的tcnative-1.dll文件删除.就可以了.
- codevs 1576最长严格上升子序列
传送门 1576 最长严格上升子序列 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 黄金 Gold 题目描述 Description 给一个数组a1, a2 ... an ...
- BZOJ3165:[HEOI2013]Segment
浅谈标记永久化:https://www.cnblogs.com/AKMer/p/10137227.html 题目传送门:https://www.lydsy.com/JudgeOnline/proble ...
- python使用uuid生成唯一id或str
介绍: UUID是128位的全局唯一标识符,通常由32字节的字符串表示. 使用: import uuid print uuid.uuid1() 14bfe806-f1c7-11e6-83b5-0680 ...
- ASP.Net MVC实现一个表单多个submit
1. 用Html.BeginForm(ActionName,ControllerName,Post)来实现controller-action的路由, 2. Form里的每个input的name值统一, ...
- SRAM SROM DRAM DROM DDR NAND FLASH EMMC的区别
RAM(Random Access Memory)的全名为随机存取记忆体,它相当于PC机上的移动存储,用来存储和保存数据的.它在任何 时候都可以读写,RAM通常是作为操作系统或其他正在运行程序的临时存 ...
- Excel中导入到oracle使用merge into 差异性更新数据库
merge into temp1 ausing (select ID from (Select ID from temp1 ...
- [hiho1584]Bounce
题意:找出图中经过一次的格子个数. 解题关键: 组合数学的思想:先找出总的经过格子的次数,然后减去2倍的经过2次的格子个数. 1.总的求法:将长延展,当延展到n倍时,能够恰好到达右边的两个端点,则总格 ...
- Golang : pflag 包简介
笔者在前文中介绍了 Golang 标准库中 flag 包的用法,事实上有一个第三方的命令行参数解析包 pflag 比 flag 包使用的更为广泛.pflag 包的设计目的就是替代标准库中的 flag ...