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. linux 网络编程getdomainname与gethostname函数

    getdomainname与gethostname函数 1 gethostname() : 返回本地主机的标准主机名. 原型如下: #include <unistd.h> int geth ...

  2. linux 进程学习笔记-消息队列messagequeue

    可以想象,如果两个进程都可以访问同一个队列:其中一个进程(sender)向其中写入结构化数据,另外一个进程(receiver)再从其中把结构化的数据读取出来.那么这两个进程就是在利用这个队列进行通信了 ...

  3. hdu 5730 Shell Necklace —— 分治FFT

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5730 DP式:\( f[i] = \sum\limits_{j=1}^{i} f[i-j] * a[j] ...

  4. 【转】Pro Android学习笔记(二):开发环境:基础概念、连接真实设备、生命周期

    在Android学习笔记(二):安装环境中已经有相应的内容.看看何为新.这是在source网站上的Android架构图,和标准图没有区别,只是这张图颜色好看多了,录之.本笔记主要讲述Android开发 ...

  5. AI-Info-Micron-Insight:Micron 美光的技术帮助 CERN 解开宇宙奥秘

    ylbtech-AI-Info-Micron-Insight:Micron 美光的技术帮助 CERN 解开宇宙奥秘 1.返回顶部 1. Micron 美光的技术帮助 CERN 解开宇宙奥秘 大约 14 ...

  6. Unix Timestamp

    class Foundation_API DateTime /// This class represents an instant in time, expressed /// in years, ...

  7. source和sh执行脚本时的差异

    在CentOS7下,有如下脚:sh02.sh. 1 用sh或者bash执行 先执行echo $firstname $lastname 再执行 sh sh02.sh 最后执行 echo $firstna ...

  8. unique()函数

    unique()是c++里面的一个去重函数,包含在<iostream>中. 该函数将重复的元素移至容器的末尾,返回的为前面的无重复项的尾地址. 由于返回的是地址,所以经常需要转换为数值使用 ...

  9. Adding In-App Purchase to your iOS and OS X Applications

    Adding In-App Purchase to your iOS and OS X Applications In-App Purchase allows you to sell addition ...

  10. Uncommon Words from Two Sentences

    https://leetcode.com/problems/uncommon-words-from-two-sentences We are given two sentences A and B.  ...