zoukankan      html  css  js  c++  java
  • Codeforces Round #438 C. Qualification Rounds

    Description

    Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it as a problemset.
    k experienced teams are participating in the contest. Some of these teams already know some of the problems. To make the contest interesting for them, each of the teams should know at most half of the selected problems.
    Determine if Snark and Philip can make an interesting problemset!

    解题报告:

    猜一个结论:如果存在答案,那么一定存在只由两个问题组成的problemset的解,所以枚举一个串,另一个串用桶判断即可

    #include <algorithm>
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    #include <cmath>
    #define RG register
    #define il inline
    #define iter iterator
    #define Max(a,b) ((a)>(b)?(a):(b))
    #define Min(a,b) ((a)<(b)?(a):(b))
    using namespace std;
    const int N=1e5+5,K=6;
    int t[3][3][3][3],f[6],n,k;int map[N][K];bool flag=false;
    void dfs(int x,int dep){
       if(dep==k+1){
          if(t[f[1]][f[2]][f[3]][f[4]])flag=true;
          return ;
       }
       if(flag)return ;
       if(map[x][dep])f[dep]=false,dfs(x,dep+1);
       else{
          f[dep]=true;dfs(x,dep+1);
          f[dep]=false;dfs(x,dep+1);
       }
    }
    void work()
    {
       cin>>n>>k;
       for(int i=1;i<=n;i++){
          for(int j=1;j<=k;j++){
             scanf("%d",&map[i][j]);
          }
          t[map[i][1]][map[i][2]][map[i][3]][map[i][4]]++;
       }
       memset(f,0,sizeof(f));
       for(int i=1;i<=n;i++){
          flag=false;
          dfs(i,1);
          if(flag){
             puts("YES");
             return ;
          }
       }
       puts("NO");
    }
    
    int main()
    {
    	work();
    	return 0;
    }
    
    
  • 相关阅读:
    小组自评、互评及反馈
    "一个程序员的生命周期"读后感
    阅读《构建之法》第10-12章
    阅读《构建之法》第8,9,10章
    冒泡算法程序分析树的评论
    1014 C语言文法定义与C程序的推导过程
    0917 实验一词法分析程序
    0909 我与编译原理不得不说的秘密
    复利计算器4
    复利及单利计算
  • 原文地址:https://www.cnblogs.com/Yuzao/p/7630563.html
Copyright © 2011-2022 走看看