Submission #993673


Source Code Expand

n, m = map(int, raw_input().split())
g = [[] for i in xrange(m)]
for i in xrange(n):
    ipt = map(int, raw_input().split())
    k = ipt[0]
    for e in ipt[1:]:
        g[e-1].append(i)
parent = range(n)
def root(x):
    if x == parent[x]:
        return x
    parent[x] = root(parent[x])
    return parent[x]
def unite(x, y):
    px = root(x)
    py = root(y)
    if px < py:
        parent[py] = px
    elif px > py:
        parent[px] = py
    return min(px, py)
for e in g:
    for i in xrange(len(e)-1):
        unite(e[i], e[i+1])
for i in xrange(n):
    root(i)
print "YES"*(sum(parent) == 0) or "NO"

Submission Info

Submission Time
Task C - Interpretation
User yaketake08
Language Python (2.7.6)
Score 400
Code Size 636 Byte
Status AC
Exec Time 538 ms
Memory 16872 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 200 / 200
Status
AC × 2
AC × 12
AC × 25
Set Name Test Cases
sample sample-01.txt, sample-02.txt
dataset1 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
dataset2 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt
Case Name Status Exec Time Memory
01-01.txt AC 16 ms 2696 KB
01-02.txt AC 17 ms 2696 KB
01-03.txt AC 20 ms 2696 KB
01-04.txt AC 20 ms 2696 KB
01-05.txt AC 20 ms 2696 KB
01-06.txt AC 19 ms 2696 KB
01-07.txt AC 19 ms 2696 KB
01-08.txt AC 19 ms 2696 KB
01-09.txt AC 19 ms 2696 KB
01-10.txt AC 21 ms 2696 KB
02-01.txt AC 194 ms 13800 KB
02-02.txt AC 493 ms 9476 KB
02-03.txt AC 199 ms 9192 KB
02-04.txt AC 393 ms 15720 KB
02-05.txt AC 449 ms 9220 KB
02-06.txt AC 397 ms 15720 KB
02-07.txt AC 477 ms 9732 KB
02-08.txt AC 465 ms 8964 KB
02-09.txt AC 538 ms 16872 KB
02-10.txt AC 298 ms 12120 KB
02-11.txt AC 297 ms 12100 KB
02-12.txt AC 308 ms 11984 KB
02-13.txt AC 309 ms 11984 KB
sample-01.txt AC 16 ms 2696 KB
sample-02.txt AC 16 ms 2696 KB