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 test(s)
input
3
1 1
3 2 4 1
2 10 11
output
YES
NO
YES
input
2
1 1
1 1
output
NO
NO AC代码:
 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct
{
int t;
int a[];
char str[];
}Play;
Play player[];
int cmp(const void *a,const void *b)
{
return *(int *)a-*(int *)b;
} int find(int m,int i)
{
int l,r,mid;
l = ;
r = player[i].t-;
while(l <= r)
{
mid = (l + r) >> ;
if(m == player[i].a[mid])
return ;
if(m < player[i].a[mid])
r = mid - ;
else
l = mid + ;
}
return ;
} int main()
{
int n,i,j,k;
int flag,t;
while(~scanf("%d",&n))
{
for(i = ;i < n;i ++)
strcpy(player[i].str,"YES");
for(i = ;i < n;i ++)
{
scanf("%d",&t);
player[i].t = t;
for(j = ; j < t; j ++)
{
scanf("%d",&player[i].a[j]);
}
qsort(player[i].a,t,sizeof(player[i].a[]),cmp);
}
for(i = ;i < n;i ++)
{
if(!strcmp(player[i].str,"YES"))
{
for(j = i + ;j < n;j ++)
{
flag = ;
if(!(player[i].t < player[j].t))
{
for(k = ; k < player[j].t;k ++)
{
if(find(player[j].a[k],i))
flag = ;
}
if(!flag)
{
strcpy(player[i].str,"NO");
if(player[i].t == player[j].t)
strcpy(player[j].str,"NO");
}
}
else
{
for(k = ;k < player[i].t;k ++)
{
if(find(player[i].a[k],j))
flag = ;
}
if(!flag)
strcpy(player[j].str,"NO");
}
}
}
}
for(i = ;i < n;i ++)
printf("%s\n",player[i].str);
}
return ;
}

B. Berland Bingo的更多相关文章

  1. CF 370B Berland Bingo

    题目链接: 传送门 Berland Bingo time limit per test:1 second     memory limit per test:256 megabytes Descrip ...

  2. CF 217 B. Berland Bingo

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

  3. cf B. Berland Bingo

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

  4. cf723d Lakes in Berland

    The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cel ...

  5. CF723D. Lakes in Berland[DFS floodfill]

    D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. codeforces 723D: Lakes in Berland

    Description The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × ...

  7. Codeforces Round #Pi (Div. 2) B. Berland National Library set

    B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  8. Codeforces Round #375 (Div. 2)——D. Lakes in Berland(DFS连通块)

    D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #375 (Div. 2) D. Lakes in Berland dfs

    D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. 通过 OpenNI 建立 Kinect 3D Point Cloud

    這篇還是算延續前一篇的<透過 OpneNI 合併 Kinect 深度以及彩色影像資料>.在可以透過 OpenNI 讀取到 Kinect 的深度.色彩資訊之後,其實就可以試著用這些資訊,來重 ...

  2. IQueryable接口与IEnumberable区别

    IEnumerable<T> 泛型类在调用自己的SKip 和 Take 等扩展方法之前数据就已经加载在本地内存里了,而IQueryable<T> 是将Skip ,take 这些 ...

  3. linux驱动(一)

    编写模块必须先声明下面两句: #include <linux/module.h>               //这个头文件包含了许多符号与函数的定义,这些符号与函数多与加载模块有关 #i ...

  4. DIV+CSS 网页布局之:三列布局

    1.宽度自适应三列布局 三列布局的原理和两列布局的原理是一样的,只不过多了一列,只需给宽度自适应两列布局中间再加一列,然后重新计算三列的宽度,就实现了宽度自适应的三列布局. 同样的道理,更多列的布局, ...

  5. sass进阶篇总结一

    一.@if 指令: @if 指令是一个 SassScript,它可以根据条件来处理样式块,如果条件为 true 返回一个样式块,反之 false 返回另一个样式块.在 Sass 中除了 @if 之,还 ...

  6. 解决cocos2d 热更是连不上https服务器

    最近苹果宣布所有上架应用都要用https,我们后端走的是同一个函数,导致Android也要连接https. 百度了下,网上说客户端不需要做什么特殊处理,因为cocos本身是支持https的.但是服务端 ...

  7. NET Portability Analyzer

    NET Portability Analyzer 分析迁移dotnet core 大多数开发人员更喜欢一次性编写好业务逻辑代码,以后再重用这些代码.与构建不同的应用以面向多个平台相比,这种方法更加容易 ...

  8. JVM 找出最耗 cpu的线程 并打印线程栈

    监控JVM中最占cpu的线程 top -Hp pid JVM中最占cpu的线程ID -o THREAD,tid,time | awk 'BEGIN {count=0; } { if($2>0.3 ...

  9. Unity给力插件之MegaFiers

    这是一个关于网格变形的插件.其中有非常多的功能. 这是它的API地址:http://www.west-racing.com/mf/ 花了2天的时间实践并整理了其中绝大多数的功能,只有一些关于特殊格式的 ...

  10. Memcached(一)在Windows上安装和测试memcached

    1)下载memcached的windows安装程序 memcached-1.2.4-Win32-Preview-20080309_bin.zip 或其他版本 2)解压memcached  用管理员身份 ...