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个不同字母的串,从中挑选出两个连续的子串,要求两个子串中含有不同的字符,问这样的两个子串长度乘积最大是多少 ...
随机推荐
- listen 55
There are also green card qualifiers for some non-citizens who invest in America, and for refugees.难 ...
- leetcode 102 Binary Tree Level Order Traversal(DFS||BFS)
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...
- 牛客网暑期ACM多校训练营(第三场)G:Coloring Tree(函数的思想)
之前两次遇到过函数的思想的题,所以这次很敏感就看出来了.可以参考之前的题: https://www.cnblogs.com/hua-dong/p/9291507.html Christmas is c ...
- BZOJ1146:[CTSC2008]网络管理
浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 题目传送门:https://www.lydsy.com/JudgeOnline/prob ...
- 微信开放平台开发-授权、全网发布(PHP)
这两天做了微信开发平台的开发,梳理下... 浙江百牛信息技术bainiu.ltd整理发布于博客园 先看看授权的流程: 第一步:接收component_verify_ticket: 1.微信服务器每隔1 ...
- MSTAR 平台
MApp_Menu.c ZUI_exefunc.h //菜单属性 MApp_ZUI_APItables.h #define GETWNDINFO(hwnd) (&g_GUI_WindowLis ...
- POJ2182(排队问题)
Lost Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10695 Accepted: 6865 Descri ...
- NSCLIENT++可以采集的指标
Documentation Information Commands/Modules CheckDisk CheckFileSize CheckDriveSize CheckF ...
- Stored Procedures CASE 用法错误
)) ) select @type=[type] from sys.objects with(nolock) where name=@ObjectName case @typ ...
- 微信小程序开发之带搜索记录的搜索框
实现功能:点击搜索框,有搜索记录时以下拉菜单显示,点击下拉子菜单,将数据赋值到搜索框,点击搜索图标搜索,支持清空历史记录,可手动输入和清空查询关键字, UI: wxml: <!--查询历史记录数 ...