• Wannafly Camp 2020 Day 5A Alternative Accounts


    There are n different accounts on the website, and some of them competed in the recent k contests. However, Mike suspects that there are lots of alternative accounts.

    There are axioms believed by everyone that nobody can use two different in one contest simultaneously and each account can be owned by only one person. So different accounts without overlapping contest participation can be owned by the same person.

    Mike wants to know the minimum possible number of different people behind these accounts.

    k=1

    太简单,直接输出个数即可

    k=2

    max个数即可

    k=3

    把数字按照它出现的集合分为8类

    1类为在所有集合中都出现,这类直接加进答案即可

    2,3,4类为在某两个集合中出现,5,6,7类为在某一个集合中出现,8类为没有出现,其中第8类不用计入答案

    首先将2类与5类中的一部分“匹配”掉并加入答案,同3-6,同4-7

    如果2,3,4类中有剩余,那么这些一定是要被单独算答案的

    5,6,7类单独算答案的贡献就是它们的max

    我居然把它写RE了(捂脸爪巴爪巴

    #include <bits/stdc++.h>
    using namespace std;
    int n,k,t1,t2,a[9][1000005],s[40];
    vector <int> v[9];
    int main() {
        scanf("%d%d",&n,&k);
        for(int i=1;i<=k;i++) {
            scanf("%d",&t1);s[i]=t1;
            for(int j=1;j<=t1;j++) {
                scanf("%d",&t2);
                a[i][t2]=1;
            }
        }
        if(k==1) cout<<t1<<endl;
        if(k==2) {
            cout<<max(s[1],s[2])<<endl;
        }
        if(k==3) {
            for(int i=1;i<=n;i++) {
                if(a[1][i]==0 && a[2][i]==0 && a[3][i]==0) v[8].push_back(i);
                if(a[1][i]==1 && a[2][i]==1 && a[3][i]==1) v[1].push_back(i);
                if(a[1][i]==0 && a[2][i]==1 && a[3][i]==1) v[2].push_back(i);
                if(a[1][i]==1 && a[2][i]==0 && a[3][i]==1) v[3].push_back(i);
                if(a[1][i]==1 && a[2][i]==1 && a[3][i]==0) v[4].push_back(i);
                if(a[1][i]==1 && a[2][i]==0 && a[3][i]==0) v[5].push_back(i);
                if(a[1][i]==0 && a[2][i]==1 && a[3][i]==0) v[6].push_back(i);
                if(a[1][i]==0 && a[2][i]==0 && a[3][i]==1) v[7].push_back(i);
            }
            int ans = 0;
            ans += v[1].size();
            while(v[2].size() && v[5].size()) ++ans, v[2].pop_back(), v[5].pop_back();
            while(v[3].size() && v[6].size()) ++ans, v[3].pop_back(), v[6].pop_back();
            while(v[4].size() && v[7].size()) ++ans, v[4].pop_back(), v[7].pop_back();
            ans += v[2].size() + v[3].size() + v[4].size();
            ans += max(v[5].size(), max(v[6].size(), v[7].size()));
            cout<<ans<<endl;
        }
    
    }
    
  • 相关阅读:
    APP测试--功能测试
    笨方法学python--读文件
    笨方法学python--参数,解包,变量
    Jmeter工具学习(四)——插件安装及使用(转载)
    JMeter工具学习(三)——获取全局变量 token
    FROM_UNIXTIME()时间戳转换函数
    软件测试用例编写规范总结(转载)
    Jmeter之Bean shell使用(二)(转载)
    JMeter工具学习(一)工具使用详细介绍
    JMeter工具学习(二)——获取登录 token
  • 原文地址:https://www.cnblogs.com/mollnn/p/12257143.html
Copyright © 2020-2023  润新知