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的更多相关文章

  1. Water --- CSU 1550: Simple String

    Simple String Problem's Link:   http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1550 Mean: 略. analy ...

  2. 1550: Simple String (做得少的思维题,两个字符串能否组成另外一个字符串问题)

    1550: Simple String Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Submitt ...

  3. csu 1550(字符串处理思路题)

    1550: Simple String Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 481  Solved: 211[Submit][Status][ ...

  4. (比赛)A - Simple String Problem

    A - Simple String Problem Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%lld & ...

  5. FZU - 2218 Simple String Problem(状压dp)

    Simple String Problem Recently, you have found your interest in string theory. Here is an interestin ...

  6. CSU - 1550 Simple String —— 字符串

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 题解: 1.A+B 与C的交集必须>=n 2.A与C的交集必须>= ...

  7. 1550: Simple String 最大流解法

    http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 很久以前做的一题,当时队友用最大流做,现在我也是 这个转化为二分图多重匹配,就是一样的意 ...

  8. FZU 2218 Simple String Problem(简单字符串问题)

    Description 题目描述 Recently, you have found your interest in string theory. Here is an interesting que ...

  9. FZU - 2218 Simple String Problem 状压dp

    FZU - 2218Simple String Problem 题目大意:给一个长度为n含有k个不同字母的串,从中挑选出两个连续的子串,要求两个子串中含有不同的字符,问这样的两个子串长度乘积最大是多少 ...

随机推荐

  1. CodeForces 547E:Mike and Friends(AC自动机+DFS序+主席树)

    What-The-Fatherland is a strange country! All phone numbers there are strings consisting of lowercas ...

  2. HihoCoder1642 : 三角形面积和([Offer收割]编程练习赛37)(求面积)(扫描线||暴力)(占位)

    描述 如下图所示,在X轴上方一共有N个等腰直角三角形.这些三角形的斜边与X轴重合,斜边的对顶点坐标是(Xi, Yi). (11,5) (4,4) /\ /\(7,3) \ / \/\/ \ / /\/ ...

  3. bzoj 4319: Suffix reconstruction 后缀数组+构造

    题目大意 给定后缀数组sa,要求构造出满足sa数组的字符串.或输出无解\(n\leq 5*10^5\) 题解 我们按照字典序来考虑每个后缀 对于\(Suffix(sa[i])\)和\(Suffix(s ...

  4. poj2228Naptime——环形DP

    题目:http://poj.org/problem?id=2228 dp[i][j][0/1]表示前i小时中第j小时睡(1)或不睡(0)的最优值: 注意第一个小时,若睡则对最终取结果有要求,即第n个小 ...

  5. spring boot 学习三:OAuth2 认证

    1:  代码地址: https://github.com/liufeiSAP/uaa-zuul 2:     安装: postgres 下载 https://www.openscg.com/bigsq ...

  6. bzoj4763

    $分块$ $一个很有趣的技巧$ $在树上选sqrt(n)个关键点,每两个关键点之间的距离<=sqrt(n),每个关键点属于一条链$ $预处理出每两个关键点的bitset$ $每次询问就暴力向上爬 ...

  7. 生成分布式随机ID

    经测试,最快的一种 public class Generator { // should be between 40 (34 years) and 42 (139 years) ; // should ...

  8. [hdu3078]Network(LCA+排序)

    题意:维护树上两点之间的最短路径,其一,将点a的值变为b,其二,求路径上第k大的值. 解题关键:LCA+sort 复杂度:$O(qn\log n + n\log n)$ 数据弱不怪我 //#pragm ...

  9. hbase&nbsp;multiple&nbsp;SLF4J&amp;n…

    hbase multiple SLF4J bindings 警告 hbase shell 和命令操作中经常有个烦人的警告,说SLF4J有多个绑定: hbase(main):003:0> list ...

  10. # program once 用途 及与 ifndef使用异同

    在头文件中用这种写法就是为了该头文件被重复包含时不会出现符合重定义的错误. 效果等同于     #ifndef __xxx__     #define __xxx__     ...    #endi ...