CF 370B Berland Bingo
题目链接: 传送门
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的更多相关文章
- cf B. Berland Bingo
http://codeforces.com/contest/370/problem/B 题意:给你n个卡片,卡片上有m个不同的数字,这个游戏是随即的从袋子里面抽球,球上有数字1-100:如果第ith玩 ...
- CF 217 B. Berland Bingo
http://codeforces.com/contest/370/problem/B 题意 :呃,这个题我说不清楚....就是有n个人,第 i 个人手里有 mi 张牌,如果,现在主人念数,念到哪张牌 ...
- B. Berland Bingo
Lately, a national version of a bingo game has become very popular in Berland. There are n players p ...
- Edu Cf Round 105 (Div. 2) B. Berland Crossword 1.读懂题, 2. 思维
一. 原题链接 https://codeforces.com/contest/1494/problem/B 二. 题意 + 题解: 没看懂题目, 懵了好久, 先狡辩一下当时误解的句子, 英语是硬伤 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
- [CF1005F]Berland and the Shortest Paths_最短路树_堆优化dij
Berland and the Shortest Paths 题目链接:https://www.codeforces.com/contest/1005/problem/F 数据范围:略. 题解: 太鬼 ...
- ATC/TC/CF
10.25 去打 CF,然后被 CF 打了. CF EDU 75 A. Broken Keyboard 精神恍惚,WA 了一发. B. Binary Palindromes 比赛中的憨憨做法,考虑一个 ...
- CF round #622 (div2)
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...
- 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 ...
随机推荐
- JavaScript的一些知识碎片(1)
打算把使用Javascript的水平从child提升到小学毕业,近期会持续记录一些知识点. javascript的引用机制:只要一个对象赋值为另一个对象,就建立了引用.一旦建立了引用,对象们就公用一块 ...
- .NET程序迁移到Mysql的极简方案——让GGTalk同时支持Sqlserver与mysql全程记录!
园子里的这个GGTalk,咱们前前后后用它移花接木做的IM项目也不下三四个了.初次入手的时候,洋洋代码,多少感觉有些难以把握.不过一来二去,理清了头绪,也就一览无余了.相信跟我们一样想要利用GGTal ...
- 论javascript中的原始值和对象
javascript将数据类型分为两类:原始值(undefined.null.布尔值.数字和字符串),对象(对象.函数和数组) 论点:原始值不可以改变,对象可以改变:对象为引用类型: '原始值不可以改 ...
- 如何阻止SELECT * 语句
我们每个人都知道是个不好的做法,但有时我们还是要这样做:我们执行SELECT * 语句.这个方法有很多弊端: 你从你的表里返回每个列,甚至后期加的列.想下如果你的查询里将来加上了VARCHAR(MAX ...
- Bootstrap系列 -- 41. 带表单的导航条
有的导航条中会带有搜索表单,在Bootstrap框架中提供了一个“navbar-form”,使用方法很简单,在navbar容器中放置一个带有navbar-form类名的表单.navbar-left”让 ...
- crontab 定时任务
1 linux 系统需要安装crontab ;yum install vixie-cron crontabs 2 编写shell 脚本, save_dir=/var/local/mysqlbak/Ne ...
- Change Eclipse Tooltip's Color in Ubuntu
这个问题十分高级,随着Ubuntu版本的变迁这个问题的解决方案也在不断变化 最开始,SystemSettings里面可以设置工具条背景色,后来这个选项在新版本Ubuntu中消失了 我用过Ubuntu1 ...
- 50-ln 简明笔记
为文件建立链接 ln [options] existing-file [new-link] ln [options] existing-file-list directory ln可以为一个或多个文件 ...
- Day Two(Beta)
站立式会议 站立式会议内容总结 331 今天:指导队友学会xml布局及简单动画,解决了关于中文链接过滤器不能将iso编码改为utf8的情况(修改servletContainer默认编码) 遇到的问题: ...
- Beta版本冲刺———第六天
会议照片: 项目燃尽图: 1.项目进展: 该项目的Beta版本冲刺到今天就大体结束,但是小组依然困在"如何保存每次游戏的分数,并将其排序列在排行榜中"的问题上,小组四个人都在一起解 ...