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 ...
随机推荐
- myeclipse中发送邮件出现Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream
出现这个问题的原因是jar包版本不统一,解决方法如下: 我在项目导入了jar包 与myeclipse自带jar冲突了 删除Java EE 5 Libraries/javaee.jar/mail里的包有 ...
- Openwrt dnsmasq 设置要点
之前设置dnsmasq,一直没有奏效,后来摸索了一下,初步发现它的原理: 正常的流程应该是像这样的,先由client来发送DNS请求到网关,然后网关的dnsmasq处理这个请求, 再根据设置决定如何处 ...
- QTableView 添加按钮
这里说一下怎么在QTableView添加一个按钮 添加两个按钮的例子在这篇文章里:QTableView 一列添加两个按钮 效果是点击button弹出一个对话框. 看一下ButtonDelegate的代 ...
- BASH 命令以及使用方法小结
最近工作中需要写一个Linux脚本,用到了很多BASH命令,为了防止以后忘记,在这里把它们一一记下来.可能会比较乱,随便看看就好了.如果有说的不对的地方也欢迎大家指正. 1,export VAR=.. ...
- 前端框架——AmazeUI学习
AmazeUI官网: http://amazeui.org/ 前后台模板下载:链接:链接:http://pan.baidu.com/s/1c2uVfk0 密码:zuva 十大前端框架参考链接:http ...
- 【python】 [基础] 数据类型,字符串和编码
python笔记,写在前面:python区分大小写1.科学计数法,把10用e代替,1.23x10·9就是 1.23e9 或者 0.00012就是1 ...
- [AJAX系列]$.get(url,[data],[fn],[type])
$.get(url,[data],[fn],[type]) 概述 通过远程HTTP GET请求载入信息 参数 url:待载入页眉的URL地址 data:待发送key/value参数 callback: ...
- android 按钮点击效果实现 在studio下出现的错误
在照做上一篇随笔的时候 在studio下为了方便我在写完一个 btn_select.xml 文件后直接粘贴了三个文件到drawable下 结果问题来了 总是报这样一个错误: Resource is n ...
- js日期显示效果
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- mysql 根据某些字段之和排序
在自己项目中记录了比赛球队获得金银铜牌的具体奖牌数,遇到需求是按照奖牌个数排序 select a.RANK_ID,a.COUNTRY,a.GOLD,a.SILVER,a.BRONZE,a.ICON,a ...