CODE FESTIVAL 2016 Final

Submission #6435953

Source codeソースコード

N,M = map(int,input().split())
KL = [list(map(int,input().split())) for _ in [0]*N]

E = [[] for _ in [0]*(N+M)]
for i,kl in enumerate(KL):
    for l in kl[1:]:
        E[i].append(N+l-1)
        E[N+l-1].append(i)

def dist_bfs(N,E,start):
    d = [-1]*N
    d[start] = 0
    q = [start]
    while q:
        i = q.pop()
        di = d[i]
        for j in E[i]:
            if d[j]!=-1:continue
            d[j] = di+1
            q.append(j)
    return d

d = dist_bfs(N+M,E,0)
ans = d[:N].count(-1)==0
print("YES" if ans else "NO")

Submission

Task問題 C - Interpretation
User nameユーザ名 ttm8761
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 400
Source lengthソースコード長 558 Byte
File nameファイル名
Exec time実行時間 510 ms
Memory usageメモリ使用量 48648 KB

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
dataset1 200 / 200 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 200 / 200 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 17 ms 3064 KB
01-02.txt AC 18 ms 3188 KB
01-03.txt AC 22 ms 3444 KB
01-04.txt AC 22 ms 3316 KB
01-05.txt AC 21 ms 3316 KB
01-06.txt AC 21 ms 3316 KB
01-07.txt AC 20 ms 3188 KB
01-08.txt AC 21 ms 3316 KB
01-09.txt AC 21 ms 3316 KB
01-10.txt AC 22 ms 3444 KB
02-01.txt AC 199 ms 25616 KB
02-02.txt AC 496 ms 41380 KB
02-03.txt AC 184 ms 21604 KB
02-04.txt AC 428 ms 36688 KB
02-05.txt AC 462 ms 38088 KB
02-06.txt AC 427 ms 36276 KB
02-07.txt AC 501 ms 38188 KB
02-08.txt AC 445 ms 37248 KB
02-09.txt AC 510 ms 48648 KB
02-10.txt AC 306 ms 31920 KB
02-11.txt AC 304 ms 31944 KB
02-12.txt AC 316 ms 31228 KB
02-13.txt AC 328 ms 31372 KB
sample-01.txt AC 17 ms 3064 KB
sample-02.txt AC 17 ms 3064 KB