Codeforces Round #338 (Div. 2) A. Bulbs 水题
A. Bulbs
题目连接:
http://www.codeforces.com/contest/615/problem/A
Description
Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up all the bulbs?
If Vasya presses the button such that some bulbs connected to it are already turned on, they do not change their state, i.e. remain turned on.
Input
The first line of the input contains integers n and m (1 ≤ n, m ≤ 100) — the number of buttons and the number of bulbs respectively.
Each of the next n lines contains xi (0 ≤ xi ≤ m) — the number of bulbs that are turned on by the i-th button, and then xi numbers yij (1 ≤ yij ≤ m) — the numbers of these bulbs.
Output
If it's possible to turn on all m bulbs print "YES", otherwise print "NO".
Sample Input
3 4
2 1 4
3 1 3 1
1 2
Sample Output
YES
Hint
题意
给你n个开关,一共有m个灯
每个开关控制ai个灯,只要按下这个开关,那么ai个灯都会亮
问你是否可以使得所有m个灯都能够亮起来
题解:
直接把所有的灯都扫一遍,然后看看是不是都出现过就好了
代码
#include<bits/stdc++.h>
using namespace std;
int a[500];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
int x;scanf("%d",&x);
for(int j=1;j<=x;j++)
{
int y;scanf("%d",&y);
a[y]=1;
}
}
int flag = 0;
for(int i=1;i<=m;i++)
{
if(a[i]==0)
flag = 1;
}
if(flag)return puts("NO");
else puts("YES");
}
Codeforces Round #338 (Div. 2) A. Bulbs 水题的更多相关文章
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #190 (Div. 2) 水果俩水题
后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告
对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #340 (Div. 2) A. Elephant 水题
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...
- Codeforces Round #340 (Div. 2) D. Polyline 水题
D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...
- Codeforces Round #282 (Div. 1) A. Treasure 水题
A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...
- Codeforces Round #327 (Div. 2) B. Rebranding 水题
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...
随机推荐
- OS X中如何获取当前运行程序的路径
OS X的执行程序一般分为两种.一种是控制台程序,一种是带有GUI的OS X应用程序. 控制台程序往往就一个文件构成executable,而GUI应用通常是一个包(即文件夹),里面除了executab ...
- ifstream 流 判断文件是否结尾的函数eof(.xml
pre{ line-height:1; color:#800080; font-size:16px;}.sysFunc{color:#627cf6;font-style:italic;font-wei ...
- 推荐一个网站Stack Overflow
网站URL:http://stackoverflow.com 我是怎么知道这个网站的呢?其实这个网站非常出名的,相信许多人都知道.如果你不知道,请继续阅读: 一次我在CSDN上面提问,但是想要再问多几 ...
- Python状况:为什么PyPy是Python的未来?
Python 现在已经不仅仅是胶水脚本语言了. 不信?看看下面使用Python的成功案例: YouTube - 主要由 Python编写 NASA Industrial Light & Mag ...
- 数往知来 asp.net 聊天室问题解决方案<十六>
1:在服务端创建了一个负责监听的sokcet //三个:采用TCP协议. ListenSocket = new Socket(AddressFamily.InterN ...
- web.xml 配置介绍
这个不是原创,有点早了,具体从哪里来的已经记不得了.但是东西是实实在在的. 1.启动一个WEB项目的时候,WEB容器会去读取它的配置文件web.xml,读取<listener>和<c ...
- MyEclipse2015对Javascript自动提示的终极支持
2015通过集成Tern.js,进入了JS自动提示的最新时代 先看看具体效果吧: 点击链接会进入: 而tern.js已经支持相当多的框架: 关键这个提示不只是纯粹的js文件,对于jsp等等 ...
- 搭建sql注入实验环境(基于windows)
搭建服务器环境 1.下载xampp包 地址:http://www.apachefriends.org/zh_cn/xampp.html 很多人觉得安装服务器是件不容易的事,特别是要想添加MySql, ...
- 一起学习 微服务(MicroServices)-笔记
笔记 微服务特性: 1. 小 专注与做一件事(适合团队就是最好的) 2. 松耦合 独立部署 3. 进程独立 4. 轻量级通信机制 实践: 1. 微服务周边的一系列基础建设 Load Balancing ...
- jbpm4.4+ssh配置(有些使用经验很好)
http://www.cnblogs.com/cmzcheng/archive/2011/11/20/2255806.html ———————————————————————————————————— ...