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 ...
随机推荐
- .NET程序迁移到Mysql的极简方案——让GGTalk同时支持Sqlserver与mysql全程记录!
园子里的这个GGTalk,咱们前前后后用它移花接木做的IM项目也不下三四个了.初次入手的时候,洋洋代码,多少感觉有些难以把握.不过一来二去,理清了头绪,也就一览无余了.相信跟我们一样想要利用GGTal ...
- SQL基础之数据库
1.基础概念 首先要强调一点,就是我们的数据库是由数据库系统来管理的,我们登入数据库并在其上进行操作时最终均要通过数据库系统来完成.可以理解成在数据库上进行操作的是客户端,数据库系统是服务端.一个数据 ...
- 让 Generator 自启动
文章同步自个人博客:http://www.52cik.com/2016/07/11/generator-co.html 此前只是简单使用而没有真正的去研究 Generator,这次要好好折腾下这货. ...
- 学堂在线 UWP 首版
好久没有写博客了,主要是最近在写一个小小的App.<( ̄︶ ̄)> 不知道看各位有木有爱看慕课的,作为一名资深的大三学渣的我有看慕课的习惯.一直在看学堂在线的慕课,感觉质量确实还可以,但是遗 ...
- express-partials与express4.x不兼容问题
在express中设置view engine为html,express-partials会导致语法不正确,其实只要做一行代码的改动就可以 function renderer(ext){ if(ext[ ...
- X240s安装Win7 以及如何启用ExpressCache
新买了一台X240S笔记本,尝试了带的Win8正版一个月后,实在无法适应Win8,干脆退回Win7完事,以下为安装过程, 第一步:制作启动U盘 首先,下载一个iso格式的Win7安装镜像文件,利用微软 ...
- pdo知识总结
PDO 用了这么久了这里抽时间总结下: pdo (php data object) 是php5 新出来的支持 mysql 操作的一个功能.用其可代替mysqli扩展.因为是php自带的.所以我觉得效率 ...
- springMvc接受日期类型参数处理
这个问题,也即是springMvc如何进行参数类型的转换 以把client传过来一个String类型,转换为日期类型为例: 1.controller /** * 接收日期类型参数 * 注意: * sp ...
- js 技巧和细节
1. if中的各种变量返回值 一个值为 true 或者 false 的表达式.如果需要,非 Boolean 表达式也可以被转换为 Boolean 值,但是要遵循下列规则: 所有的对象都被当作 true ...
- mysql union和union all的区别
union 对两个结果集进行并集操作,重复数据只显示一次 Union All,对两个结果集进行并集操作,重复数据全部显示 工具/原料 mysql 数据库 方法/步骤 student表数据 使用 ...