Codeforces Round #338 (Div. 2) A. Bulbs 水题

时间:2022-10-27 23:48:44

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 水题的更多相关文章

  1. Codeforces Round &num;185 &lpar;Div&period; 2&rpar; B&period; Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  2. Codeforces Round &num;360 &lpar;Div&period; 2&rpar; A&period; Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  3. Codeforces Round &num;190 &lpar;Div&period; 2&rpar; 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  4. Codeforces Round &num;256 &lpar;Div&period; 2&sol;A&rpar;&sol;Codeforces448A&lowbar;Rewards&lpar;水题&rpar;解题报告

    对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...

  5. Codeforces Round &num;340 &lpar;Div&period; 2&rpar; B&period; Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  6. Codeforces Round &num;340 &lpar;Div&period; 2&rpar; A&period; Elephant 水题

    A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...

  7. Codeforces Round &num;340 &lpar;Div&period; 2&rpar; D&period; Polyline 水题

    D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...

  8. Codeforces Round &num;282 &lpar;Div&period; 1&rpar; A&period; Treasure 水题

    A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...

  9. Codeforces Round &num;327 &lpar;Div&period; 2&rpar; B&period; Rebranding 水题

    B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...

随机推荐

  1. Device Tree(二):基本概念

    转自:http://www.wowotech.net/linux_kenrel/dt_basic_concept.html 一.前言 一些背景知识(例如:为何要引入Device Tree,这个机制是用 ...

  2. Session共享的解决方案

    http://www.cnblogs.com/xinhaijulan/archive/2010/08/21/1805116.html Session共享的解决方案 1.客户端SessionID值唯一: ...

  3. 记录linux &sol;bin被误删除的解决过程

    1.事因: 执行shell测试时,shell中rm -rf $path/* 变量$path为空,结果执行的命令是rm -rf / 事发时及时ctrl+c中断,导致只有/bin /boot目录删除 2. ...

  4. DigitalOcean&lpar;DO&rpar;购买VPS流程

    背景: 对于一个程序员来说,拥有自己的一台国外服务器是一种多么激动的事情,尽管配置不如自己电脑的1/5,但是想一想可以不用备案搭建网站,可以搭建shadow服务器,从此通过自己的服务器上网,想一想真是 ...

  5. VS 2013 编译和使用 Boost

    以 1.58.0 版本 boost 为例, 当前系统版本为 Windows 8.1 x64   1 编译boost  当前解压路径 "D:\Libraries\boost_1_58_0&qu ...

  6. Java的函数与函数重载

    关于Java的函数与函数重载 关于Java的函数与函数重载 1. 函数 假设有一个游戏程序,程序在运行过程中,要不断地发射炮弹.发射炮弹的动作都需要使用一段百行左右的程序代码,在每次发射炮弹的地方都要 ...

  7. Java线程--interrupt join yield setDaemon常用方法的使用

    概念: 操作系统可以有多个进程,一个线程可以有一个或多个线程.进程与进程之间不共享内存,都在各自的空间中运行.而线程不仅可以共享内存,还可以用有一个自己的内存空间,叫做线程栈. 线程又称轻量级进程.J ...

  8. struts2&period;1&period;6教程三、在Action获取Scope对象

    引言:在前面的Action操作中,关键就是Action中的exectue方法,但是此方法并没有request.session.application等对象作为参数,自然就不能利用这些对象来操作.下面我 ...

  9. 一步一步创建ASP&period;NET MVC5程序&lbrack;Repository&plus;Autofac&plus;Automapper&plus;SqlSugar&rsqb;&lpar;十&rpar;

    前言 朋友们, 大家好,我还是Rector,写ASP.NET MVC 5系列文章[一步一步创建ASP.NET MVC5程序Repository+Autofac+Automapper+SqlSugar] ...

  10. elk安装最佳实践

    一.添加清华源 .x.repo<<EOF [elasticsearch-.x] name=Elasticsearch repository .x packages baseurl=http ...