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. ZIP压缩文件夹中上个月的文件,并将备份文件拷贝到服务器

    遍历文件夹的子文件夹下的所有文件,将上个月的文件集中到一起,然互压缩,并copy到服务器的映射磁盘. static void Main(string[] args) { //原始文件存放的位置 Dir ...

  2. OC与Swift的区别四(条件语句)

    12.条件语句的区别,此处只写区别,没有指出区别的其他方面oc与swift基本一致 12.1 oc中for if switch语句体如果只有一行代码,则{}可以省略 swift中for if swit ...

  3. Speak softly love

    Speak softly love and hold me warm against your heart 柔声诉情,拥我在你暖暖的心上 I feel your words, the tender t ...

  4. rapidxml对unicode的支持

    为了提高duilib创建布局控件的效率,在LuaDui项目中使用rapidxml解析器替换了duilib库自带的xml解析器. duilib使用unicode编译,所以rapidxml需要解析unic ...

  5. windows下使用xampp一键安装apache+php运行环境

    感谢浏览,欢迎交流=.= 想为我老爸开发一套库存管理系统,借此机会打算使用下ext+php+apache+linux环境尝尝鲜. 为了在windows搭建本地开发测试环境,官网下载xampp,一键安装 ...

  6. 《sort命令的k选项大讨论》-linux命令五分钟系列之二十七

    本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...

  7. variable-precision SWAR算法:计算Hamming Weight

    variable-precision SWAR算法:计算Hamming Weight 转自我的Github 最近看书看到了一个计算Hamming Weight的算法,觉得挺巧妙的,纪录一下. Hamm ...

  8. Jquery操作单选按钮(Radio)的取值赋值实现代码

    1.获取选中值,三种方法都可以: $('input:radio:checked').val(); $("input[type='radio']:checked").val(); $ ...

  9. PHP 文字,图片水印,缩略图,裁切成小图(大小变小)

    文字水印基本思路:1.用getimagesize()获取图片的信息(as:大小,属性等):2.根据图片信息用imagecreatefromjpeg ()/imagecreatefromgif/imag ...

  10. 支付宝开发(一)-认识php openssl RSA 非对称加密实现

    获取支付宝公钥 本地服务器生成私钥和公钥 运用php中openssl相关函数加密解密验证身份 以下是php中openssl相关函数实现的验证,来自php官方demo //需要签名的数据 $data = ...