Submission #7708723
Source Code Expand
import sys import heapq import bisect import itertools mod = 10**9+7 dd = ((-1,0),(1,0),(0,-1),(0,1)) def I(): return(int(sys.stdin.readline())) def LI(): return([int(x) for x in sys.stdin.readline().split()]) def LI_(): return([int(x)-1 for x in sys.stdin.readline().split()]) def S(): return(sys.stdin.readline()[:-1]) def IR(n): return([I() for _ in range(n)]) def GCD(a,b): while b!=0: a,b = b,a%b return a def LCM(a,b): return a * b // GCD(a,b) def Eratosthenes(N): r = [True]*(N+1) r[0] = False r[1] = False i = 2 while i*i<=N: if r[i]: j = i while i*j<=N: prime[i*j]=False j+=1 i+=1 return(r) def main(): N,M = LI() ll = [[] for _ in range(N)] dic = {} for i in range(N): KL = LI() ll[i] = [j-1 for j in KL[1:]] for l in KL[1:]: dic[l-1] = dic.get(l-1,[]) dic[l-1].append(i) flagk = [True] * N flagl = {} for l in dic: flagl[l] = True que = [0] while que: k = que.pop() if flagk[k]: flagk[k] = False for l in ll[k]: if flagl[l]: flagl[l] = False for nxt in dic[l]: if flagk[nxt]: que.append(nxt) for x in flagk: if x: return("NO") return("YES") if __name__ == "__main__": print(main())
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | lisbun |
Language | PyPy3 (2.4.0) |
Score | 400 |
Code Size | 1493 Byte |
Status | AC |
Exec Time | 378 ms |
Memory | 71152 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 200 / 200 | ||||||
Status |
|
|
|
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 | 165 ms | 38256 KB |
01-02.txt | AC | 168 ms | 38640 KB |
01-03.txt | AC | 180 ms | 38768 KB |
01-04.txt | AC | 178 ms | 38768 KB |
01-05.txt | AC | 180 ms | 38768 KB |
01-06.txt | AC | 175 ms | 38640 KB |
01-07.txt | AC | 173 ms | 38768 KB |
01-08.txt | AC | 175 ms | 38640 KB |
01-09.txt | AC | 173 ms | 38768 KB |
01-10.txt | AC | 178 ms | 38768 KB |
02-01.txt | AC | 303 ms | 59740 KB |
02-02.txt | AC | 354 ms | 64288 KB |
02-03.txt | AC | 327 ms | 62428 KB |
02-04.txt | AC | 366 ms | 64604 KB |
02-05.txt | AC | 378 ms | 64380 KB |
02-06.txt | AC | 362 ms | 64232 KB |
02-07.txt | AC | 372 ms | 62956 KB |
02-08.txt | AC | 303 ms | 64304 KB |
02-09.txt | AC | 316 ms | 68528 KB |
02-10.txt | AC | 298 ms | 71152 KB |
02-11.txt | AC | 300 ms | 70128 KB |
02-12.txt | AC | 311 ms | 67932 KB |
02-13.txt | AC | 306 ms | 66780 KB |
sample-01.txt | AC | 164 ms | 38256 KB |
sample-02.txt | AC | 165 ms | 38256 KB |