zoukankan      html  css  js  c++  java
  • D

    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 = 123456;
    char str[maxn], sub1[maxn], sub2[maxn];
    int hasStr[222], hasSub1[222], hasSub2[222];
    void work() {
        int lenstr = strlen(str + 1);
        memset(hasStr, 0, sizeof hasStr);
        memset(hasSub1, 0, sizeof hasSub1);
        memset(hasSub2, 0, sizeof hasSub2);
        for (int i = 1; i <= lenstr; ++i) hasStr[str[i]]++;
        for (int i = 1; i <= lenstr; ++i) hasSub1[sub1[i]]++;
        for (int i = 1; i <= lenstr; ++i) hasSub2[sub2[i]]++;
        int ans1 = 0, ans2 = 0, ans3 = 0;
        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 / 2 || ans2 < lenstr / 2 || ans3 < lenstr) {
            printf("NO
    ");
        } else printf("YES
    ");
    }
    
    int main() {
    #ifdef local
        freopen("data.txt", "r", stdin);
    //    freopen("data.txt", "w", stdout);
    #endif
        while (scanf("%s%s%s", sub1 + 1, sub2 + 1, str + 1) > 0) work();
        return 0;
    }
    View Code
  • 相关阅读:
    开发自定义控件步骤
    asp.net后台调用前台js代码
    使用ResolveUrl设置相对路径
    JavaScript获取后台C#变量以及调用后台方法
    使用jquery的验证插件进行客户端验证
    参数化的模糊查询
    使用Microsoft Enterprise Library 5.0记录日志信息
    我的Ajax学习笔记
    我的工作問題集(VS2005)
    存储过程从入门到精通(转载)
  • 原文地址:https://www.cnblogs.com/liuweimingcprogram/p/6934767.html
Copyright © 2011-2022 走看看