题目链接: 传送门

Berland Bingo

time limit per test:1 second     memory limit per test:256 megabytes

Description

Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have equal numbers. The card of the i-th player contains mi numbers.
During the game the host takes numbered balls one by one from a bag. He reads the number aloud in a high and clear voice and then puts the ball away. All participants cross out the number if it occurs on their cards. The person who crosses out all numbers from his card first, wins. If multiple people cross out all numbers from their cards at the same time, there are no winners in the game. At the beginning of the game the bag contains 100 balls numbered 1 through 100, the numbers of all balls are distinct.
You are given the cards for each player. Write a program that determines whether a player can win the game at the most favorable for him scenario or not.

Input

The first line of the input contains integer n (1 ≤ n ≤ 100) — the number of the players. Then follow n lines, each line describes a player's card. The line that describes a card starts from integer mi (1 ≤ mi ≤ 100) that shows how many numbers the i-th player's card has. Then follows a sequence of integers ai, 1, ai, 2, ..., ai, mi (1 ≤ ai, k ≤ 100) — the numbers on the i-th player's card. The numbers in the lines are separated by single spaces.
It is guaranteed that all the numbers on each card are distinct.

Output

Print n lines, the i-th line must contain word "YES" (without the quotes), if the i-th player can win, and "NO" (without the quotes) otherwise.

Sample Input

3
1 1
3 2 4 1
2 10 11

2
1 1
1 1

Sample Output

YES
NO
YES

NO
NO

解题思路:

题目大意:每个人手上都有几个数字,裁判扔数字,当自己手上有跟裁判扔出的数字一样的数,就把这张牌丢弃,问谁能胜利
其实这题就是问那个人没有子集,没有子集的最后都能胜利。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;

bool OK(vector<int>a,vector<int>b)//a in b?
{
    int lena = a.size();
    int lenb = b.size();
    for (int i = 0;i < lena;i++)
    {
        bool in = false;
        for (int j = 0;j < lenb;j++)
        {
            if (a[i] == b[j])
            {
                in = true;
            }
        }
        if (!in)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int N;
    while (~scanf("%d",&N))
    {
        vector<int>itv[105];
        int ans[105] = {0};
        int M,tmp;
        for (int i = 0;i < N;i++)
        {
            scanf("%d",&M);
            while (M--)
            {
                scanf("%d",&tmp);
                itv[i].push_back(tmp);
            }
        }
        for (int i = 0;i < N;i++)
        {
            for (int j = 0;j < N;j++)
            {
                if (j == i) continue;
                if (OK(itv[i],itv[j]))
                {
                    ans[j] = 1;
                }
            }
        }
        for (int i = 0;i < N;i++)
        {
            if (!ans[i])
            {
                printf("YES\n");
            }
            else
            {
                printf("NO\n");
            }
        }
    }
    return 0;
} 

CF 370B Berland Bingo的更多相关文章

  1. cf B. Berland Bingo

    http://codeforces.com/contest/370/problem/B 题意:给你n个卡片,卡片上有m个不同的数字,这个游戏是随即的从袋子里面抽球,球上有数字1-100:如果第ith玩 ...

  2. CF 217 B. Berland Bingo

    http://codeforces.com/contest/370/problem/B 题意 :呃,这个题我说不清楚....就是有n个人,第 i 个人手里有 mi 张牌,如果,现在主人念数,念到哪张牌 ...

  3. B. Berland Bingo

    Lately, a national version of a bingo game has become very popular in Berland. There are n players p ...

  4. Edu Cf Round 105 (Div. 2) B. Berland Crossword 1.读懂题, 2. 思维

    一. 原题链接 https://codeforces.com/contest/1494/problem/B   二. 题意 + 题解: 没看懂题目, 懵了好久, 先狡辩一下当时误解的句子, 英语是硬伤 ...

  5. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

  6. [CF1005F]Berland and the Shortest Paths_最短路树_堆优化dij

    Berland and the Shortest Paths 题目链接:https://www.codeforces.com/contest/1005/problem/F 数据范围:略. 题解: 太鬼 ...

  7. ATC/TC/CF

    10.25 去打 CF,然后被 CF 打了. CF EDU 75 A. Broken Keyboard 精神恍惚,WA 了一发. B. Binary Palindromes 比赛中的憨憨做法,考虑一个 ...

  8. CF round #622 (div2)

    CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...

  9. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

随机推荐

  1. 你真的熟悉background吗?

    一两个月没更新博客了,因为放假刚在深圳找了实习,一直都比较忙碌,不过我觉得再忙,还是需要时间去沉淀一些东西,工作的时候别人看到的只是你有没有实现最终的结果,但自己是否思考,是否去总结,决定着你工作是否 ...

  2. [云上天气预报-有时有闪电]2月3日23:00-4:00阿里云SLB升级期间网络会闪断

    大家好,2月3日23:00-2月4日4:00,阿里云将对SLB(负载均衡)进行升级,在升级期间,SLB会有约4-8次的网络闪断.由此给您带来麻烦,望谅解! 阿里云官方公告内容如下: 尊敬的用户: 您好 ...

  3. js基础知识温习:Javascript中如何模拟私有方法

    本文涉及的主题虽然很基础,在很多人眼里属于小伎俩,但在JavaScript基础知识中属于一个综合性的话题.这里会涉及到对象属性的封装.原型.构造函数.闭包以及立即执行表达式等知识. 公有方法 公有方法 ...

  4. 自己存档:ajax 动态提交form

    $.ajax({                    cache: true,                    type: "POST",                  ...

  5. ArcGIS支持MongoDB数据源

    ArcGIS支持MongoDB数据源 自从NoSQL推出之后,MongoDB就作为比较杰出的代表受到广大用户的推崇,当然,与之而来的大数据的讨论也非常激烈,GIS数据源向来都是以海量来计算,所以,GI ...

  6. C程序中对时间的处理——time库函数详解

    包含文件:<sys/time.h> <time.h> 一.在C语言中有time_t, tm, timeval等几种类型的时间 1.time_t time_t实际上是长整数类型, ...

  7. Vue-loader 开启压缩后的一些坑

    在使用vue-loader 配合webpack 对.vue文件进行加载的时候,如果开启了代码压缩会出来下面几种问题,做个记录. 丢失td结束标记,导致页面的布局错乱 input的属性type为text ...

  8. js中奇特的for循环写法

    //正常的for循环 for(var i=0;i<10;i++){ console.log(i); } //输出:1,2,3……10 //简写 for(var i=10;i--;){ conso ...

  9. springMvc发布restFull风格的URL

    package zpark.controller; import org.springframework.stereotype.Controller; import org.springframewo ...

  10. webservice的常用注解

    定义说明书的显示方法1.@WebService(serviceName="PojoService", portName="PojoPort", name=&qu ...