CF 370B Berland Bingo
题目链接: 传送门
Berland Bingo
time limit per test:1 second memory limit per test:256 megabytes
Description
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 Input
3
1 1
3 2 4 1
2 10 11
2
1 1
1 1
Sample Output
YES
NO
YES
NO
NO
解题思路:
题目大意:每个人手上都有几个数字,裁判扔数字,当自己手上有跟裁判扔出的数字一样的数,就把这张牌丢弃,问谁能胜利
其实这题就是问那个人没有子集,没有子集的最后都能胜利。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
bool OK(vector<int>a,vector<int>b)//a in b?
{
int lena = a.size();
int lenb = b.size();
for (int i = 0;i < lena;i++)
{
bool in = false;
for (int j = 0;j < lenb;j++)
{
if (a[i] == b[j])
{
in = true;
}
}
if (!in)
{
return false;
}
}
return true;
}
int main()
{
int N;
while (~scanf("%d",&N))
{
vector<int>itv[105];
int ans[105] = {0};
int M,tmp;
for (int i = 0;i < N;i++)
{
scanf("%d",&M);
while (M--)
{
scanf("%d",&tmp);
itv[i].push_back(tmp);
}
}
for (int i = 0;i < N;i++)
{
for (int j = 0;j < N;j++)
{
if (j == i) continue;
if (OK(itv[i],itv[j]))
{
ans[j] = 1;
}
}
}
for (int i = 0;i < N;i++)
{
if (!ans[i])
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
}
return 0;
}
CF 370B Berland Bingo的更多相关文章
- cf B. Berland Bingo
http://codeforces.com/contest/370/problem/B 题意:给你n个卡片,卡片上有m个不同的数字,这个游戏是随即的从袋子里面抽球,球上有数字1-100:如果第ith玩 ...
- CF 217 B. Berland Bingo
http://codeforces.com/contest/370/problem/B 题意 :呃,这个题我说不清楚....就是有n个人,第 i 个人手里有 mi 张牌,如果,现在主人念数,念到哪张牌 ...
- B. Berland Bingo
Lately, a national version of a bingo game has become very popular in Berland. There are n players p ...
- Edu Cf Round 105 (Div. 2) B. Berland Crossword 1.读懂题, 2. 思维
一. 原题链接 https://codeforces.com/contest/1494/problem/B 二. 题意 + 题解: 没看懂题目, 懵了好久, 先狡辩一下当时误解的句子, 英语是硬伤 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
- [CF1005F]Berland and the Shortest Paths_最短路树_堆优化dij
Berland and the Shortest Paths 题目链接:https://www.codeforces.com/contest/1005/problem/F 数据范围:略. 题解: 太鬼 ...
- ATC/TC/CF
10.25 去打 CF,然后被 CF 打了. CF EDU 75 A. Broken Keyboard 精神恍惚,WA 了一发. B. Binary Palindromes 比赛中的憨憨做法,考虑一个 ...
- CF round #622 (div2)
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
随机推荐
- centos hadoop搭建准备
永久修改主机名:hostnamectl set-hostname <hostname> IP地址: BOOTPROTO=static IPADDR=192.168.31.128NETMAS ...
- Windows 10 后台音频
UWP版本的网易云音乐已经上架,虽然还不支持Windows Phone但是整体而言功能已经比较齐全了! 那么如何在Windows 10 UWP实现后台播放呢? 我之前是一直在做Windows Phon ...
- redis+Keepalived主从热备秒级切换
一 简介 安装使用centos 5.10 Master 192.168.235.135 Slave 192.168.235.152 Vip 192.168.235.200 编译环境 yum -y in ...
- yii2搭建完美后台并实现rbac权限控制实例教程
1.安装yii2 未安装的请参考yii2史上最简单式安装教程,没有之一 或者参考yii2实战教程之详细安装步骤 已安装的请继续看下一步操作 2.配置数据库 2.1 配置数据库 修改common/con ...
- 十天冲刺---Day8
站立式会议 站立式会议内容总结: 燃尽图 照片 最近思考一个问题.项目是怎么进行到这一步的. 算了,这个发在明天的冲刺总结吧.. 还需继续努力,队友快回来快回来..
- 关于volatile的可见性问题
volatile的定义是:volatile是轻量级的synchronized,它在多处理器开发中保证了共享变量的‘可见性’,可见性的意思是当一个线程修改一个共享变量时,另外一个线程能够读到这个修改的值 ...
- 【SPOJ 1812】Longest Common Substring II
http://www.spoj.com/problems/LCS2/ 这道题想了好久. 做法是对第一个串建后缀自动机,然后用后面的串去匹配它,并在走过的状态上记录走到这个状态时的最长距离.每匹配完一个 ...
- 素数筛 poj 3518
给你一个n 求包括n的一个非素数区间有多长 +1输出 #include<stdio.h> #include<string.h> #include<algorithm> ...
- 第一个PyQt程序
这个程序虽然小,具备pyqt程序的皱型,可以作为一个模板使用了 #!/usr/bin/python3 # -*- coding: utf-8 -*- import sys from PyQt5.QtW ...
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
原因1:给定目录下jvm.dll不存在. 对策:(1)重新安装jre或者jdk并配置好环境变量.(2)copy一个jvm.dll放在该目录下. 原因2:eclipse的版本与jre或者jdk版本不一致 ...