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;
        }
    
    }
    
  • 相关阅读:
    Linux下处理文件中的^M
    python selenium-webdriver 生成测试报告 (十四)
    Apache 配置Https 转发Tomcat Http
    自动化测试神器 之 python unittest 断言
    创建高性能索引笔记
    【转】正向代理vs反向代理
    vue 常用问题
    eslint 代码规范2
    WebStrom2018注册码
    Vue-selller 饿了吗
  • 原文地址:https://www.cnblogs.com/mollnn/p/12257143.html
Copyright © 2011-2022 走看看