zoukankan      html  css  js  c++  java
  • 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;
        }
    
    }
    
  • 相关阅读:
    全程图解】ADSL+笔记本电脑 组建WIFI网络让5800实现WIFI上网(更新完毕)
    JSP用户管理系统【上学应付作业用】
    c++按位操作符
    F#: .NET中的函数编程语言
    Visual Studio OpenGL 配置方法
    Linux下挂载U盘方法
    开发者该以什么为骄傲
    POSIX约定与GNU长选项
    修复移动硬盘"文件或目录损坏且无法读取"
    某国外论坛关于什么是Computer Science的争论,你怎么看?
  • 原文地址:https://www.cnblogs.com/mollnn/p/12257143.html
Copyright © 2011-2022 走看看