Submission #3141639


Source Code Expand

import sys
sys.setrecursionlimit(100000)

n,m=map(int,input().split())
f=lambda x:int(x)-1

langs=[[] for _ in range(m)]
speakers=[[] for _ in range(n)]
used_langs=[False]*m
used_speakers=[False]*n

for i in range(n):
  *l,=map(f,input().split()[1:])
  speakers[i].extend(l)
  for j in l:
    langs[j].append(i)

def dfs(n):
  if used_speakers[n]:
    return
  used_speakers[n]=True
  for i in speakers[n]:
    if used_langs[i]:continue
    used_langs[i]=True
    for j in langs[i]:
      dfs(j)

dfs(0)
if not False in used_speakers:
  print("YES")
else:
  print("NO")

Submission Info

Submission Time
Task C - Interpretation
User tallestorange
Language Python (3.4.3)
Score 400
Code Size 600 Byte
Status AC
Exec Time 506 ms
Memory 36812 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 200 / 200
Status
AC × 2
AC × 12
AC × 27
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, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
01-01.txt AC 17 ms 3064 KB
01-02.txt AC 18 ms 3188 KB
01-03.txt AC 22 ms 3316 KB
01-04.txt AC 21 ms 3188 KB
01-05.txt AC 21 ms 3188 KB
01-06.txt AC 20 ms 3188 KB
01-07.txt AC 20 ms 3188 KB
01-08.txt AC 21 ms 3188 KB
01-09.txt AC 20 ms 3188 KB
01-10.txt AC 22 ms 3316 KB
02-01.txt AC 170 ms 22960 KB
02-02.txt AC 478 ms 27420 KB
02-03.txt AC 177 ms 22960 KB
02-04.txt AC 367 ms 26904 KB
02-05.txt AC 415 ms 30804 KB
02-06.txt AC 372 ms 26804 KB
02-07.txt AC 470 ms 27744 KB
02-08.txt AC 412 ms 25856 KB
02-09.txt AC 506 ms 36812 KB
02-10.txt AC 286 ms 23272 KB
02-11.txt AC 292 ms 22660 KB
02-12.txt AC 292 ms 22320 KB
02-13.txt AC 290 ms 22064 KB
sample-01.txt AC 17 ms 3064 KB
sample-02.txt AC 17 ms 3064 KB