B. Berland Bingo
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.
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.
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.
3
1 1
3 2 4 1
2 10 11
YES
NO
YES
2
1 1
1 1
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的更多相关文章
- CF 370B Berland Bingo
题目链接: 传送门 Berland Bingo time limit per test:1 second memory limit per test:256 megabytes Descrip ...
- CF 217 B. Berland Bingo
http://codeforces.com/contest/370/problem/B 题意 :呃,这个题我说不清楚....就是有n个人,第 i 个人手里有 mi 张牌,如果,现在主人念数,念到哪张牌 ...
- cf B. Berland Bingo
http://codeforces.com/contest/370/problem/B 题意:给你n个卡片,卡片上有m个不同的数字,这个游戏是随即的从袋子里面抽球,球上有数字1-100:如果第ith玩 ...
- 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 ...
- CF723D. Lakes in Berland[DFS floodfill]
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 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 × ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- jeesite 一对多,对子表单独修改时出现 HV000030: No validator could be found for type:
这是由于springmvc校验功能造成的,解决办法参见我的百度回答 http://zhidao.baidu.com/question/2141673418419314468
- 滑动条 Trackbar[OpenCV 笔记9]
OpenCV中没有实现按钮的功能,我们可以利用滑动条来实现按钮功能. , ); trackbarname 轨迹条的名字. winname 窗口的名字,轨迹条会依附在这个窗口上. value 一个指向整 ...
- python 自动化之路 day 07 面向对象基础
本节内容: 面向对象编程介绍 为什么要用面向对象进行开发? 面向对象的特性:封装.继承.多态 类.方法. 面向对象编程 OOP编程是利用"类"和"对象" ...
- Graphviz使用简介(中文乱码的问题)
Graphviz使用简介 graphviz是基于dot语言的绘图工具,可以画有向图.无向图.关系图.目录图.流程图等.具体作用可见它的官方网站 一些参考的网址: http://www.open-ope ...
- js hover放大效果
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- jquery中onclick内$(this)指向
jquery中onclick=”fn”中$(this)所代表的对象 js方法 function qiehuan(){ var src = $(this).attr(“data”); alert($(t ...
- 采用python获得并修改文件编码(原创)
windows和linux采用了不同的编码,这让很多人伤透了脑经,这里我采用了Python的chardet库获得代码的编码,然后修改编码. 1.首先需要安装chardet库,有很多方式,我才用的是比较 ...
- mysql中char与varchar的区别
在建立数据库表结构的时候,为了给一个String类型的数据定义一个数据库的数据库类型,一般参考的都是char或者varchar,这两种选择有时候让人很纠结,今天想总结一下它们两者的区别,明确一下选择塔 ...
- html5 API
1.Canvas绘图 2.postMessage跨域.多窗口传输 3.requestAnimationFrame动画 4.PageVisibility API页面可见性 5.File 本地文件操作 6 ...
- 使用dynamic来简化反射实现
dynamic是Framework4.0的新特性,dynamic的出现让C#具有了弱语言类型的特性,编译器在编译的时候,不再对类型进行检查,不会报错,但是运行时如果执行的是不存在的属性或者方法,运行程 ...