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. 是么是 API 和 SDK

    API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力,而又无需访问源码 ...

  2. WPF动画之路径动画(3)

    XAML代码: <Window x:Class="路径动画.MainWindow" xmlns="http://schemas.microsoft.com/winf ...

  3. 动态加载js、css 代码

    一.原生js: /** * 加载js和css文件 * @param jsonData.path 前缀路径 * @param jsonData.url 需要加载的js路径或css路径 * @param ...

  4. 插入排序之python实现源码

    def insert_sort(old): for i in range(1, len(old)): for j in range(i, 0, -1): if(old[j] < old[j-1] ...

  5. c++ primer复习(五):类

    一:基本内容 1 类 数据成员:用于存储与类对象相关联的状态 成员函数:对数据成员进行操作 类将接口与实现分离,接口指定了类支持的操作,操作的具体实现细节是类的设计者才需要了解 2 类成员 类成员可以 ...

  6. (转)Libevent(1)— 简介、编译、配置

    转自:http://name5566.com/4190.html 参考文献列表:http://www.wangafu.net/~nickm/libevent-book/ 此文编写的时候,使用到的 Li ...

  7. html定义对象

    <object>定义一个对象<param>为对象定义一个参数 参数的名称:name = "" 参数的值:value=""classid: ...

  8. 为 DataGridView 控件添加行号

    虽然好像不经常用到,不过还是记下来防止以后用到 /// <summary> /// 为 DataGridView 控件添加行号 /// </summary> /// <p ...

  9. 强大的字符串格式化函数 - format

    自python2.6开始,新增了一种格式化字符串的函数str.format(),它通过{}和:来代替% 位置方法格式化 >>>'{}-{}'.format('simon','ting ...

  10. node 无解回调 有解了

    http://cssor.com/javascript-workflow-by-tofishes.html