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. linux管道学习(一)

    最近学习了管道 pipe,在这里进行一下总结. 这里贴一段自己的实做代码 struct node{ int a; long b; }; int main() { ]; pid_t pid; ]; in ...

  2. atc游戏bot

    游戏玩起来太虐心了,就写了个bot来玩, 代码在此: git clone https://github.com/chenfengyuan/atc-bot-new.gitgit clone https: ...

  3. C++学习指南

    转载于stackoverflow:http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list 感谢Ge ...

  4. spark - 将RDD保存到RMDB(MYSQL)数据库中

    SCALA连接数据库批量插入: scala> import java.sql.DriverManager scala> var url = "jdbc:mysql://local ...

  5. notepad++插件使用说明

    在进行渗透测试的过程中,经常需要分析一些js或xml文件,或者是一些url,它们多是经过压缩或编码的,看起来不方便.这里介绍几款常用的notepad++插件,会极大的方便我们的开发测试. 1 Xml ...

  6. shell中的条件判断

    read命令 命令的语法: read [参数] 变量名 常用的参数如下: -t timeout 设定超时时间. -p prompt 设定提示信息,该提示信息将会显在光标前. 条件测试: 条件测试可以判 ...

  7. php 加载函数 __autoload(), spl_autoload_register()

    来自:http://www.cnblogs.com/myluke/archive/2011/06/25/2090119.html spl_autoload_register (PHP 5 >= ...

  8. PHP实现斐波那契数列非递归方法

    斐波那契数列,又称黄金分割数列,指的是这样一个数列:0.1.1.2.3.5.8.13.21.……在数学上,斐波纳契数列以如下被以递归的方法定义:F0=0,F1=1,Fn=F(n-1)+F(n-2)(n ...

  9. 如何定时备份远程mysql数据库

    通常,站长们都没有自己的服务器,每天都要手动备份数据库那也很麻烦.这里推荐一个方法,利用windows的计划任务来实现. 前提:本地机器上装有mysql服务. 假设本地机器上mysql服务目录  d: ...

  10. c#反射机制判断同一个类的两个实例的值是否完全一样

    ; i < properties1.Length; i++)            {                string s = properties1[i].DeclaringTyp ...