【CodeForces】[615A]Bulbs

文章字数:140

问题描述

问题分析

给出每个按钮可点亮的灯
问能否把所有灯点亮

因为点亮后的灯不会熄灭
所以只要有按钮控制的灯都能点亮
也就是只要出现过的灯都能点亮

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<stdio.h>
#include<string.h>
int a[120];
int main() {
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF) {
        memset(a,0,sizeof(a));
        for(int i=0; i<n; i++) {
            int t;
            scanf("%d",&t);
            while(t--) {
                int tx;
                scanf("%d",&tx);
                a[tx]=1;
            }
        }
        int i;
        for(i=1; i<=m; i++) {
            if(!a[i])
                break;
        }
        printf("%s\n",i<=m?"NO":"YES");
    }
    return 0;
}

该内容采用 CC BY-NC-SA 4.0 许可协议。

如果对您有帮助或存在意见建议,欢迎在下方评论交流。

加载中...