CODE FESTIVAL 2016 Final

Submission #6436076

Source codeソースコード

import heapq
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][N+l-1] = 1
        E[N+l-1][i] = 1

def Dijkstra(N,E,start):
    d = [-1]*N
    q = [(0,start)]
    while q:
        ci,i = heapq.heappop(q)
        if d[i]!= -1:continue
        d[i] = ci
        for j,cj in E[i].items():
            if d[j]!=-1:continue
            heapq.heappush(q,(ci+cj,j))
    return d

d = Dijkstra(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ソースコード長 597 Byte
File nameファイル名
Exec time実行時間 632 ms
Memory usageメモリ使用量 106928 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 20 ms 3572 KB
01-03.txt AC 22 ms 3956 KB
01-04.txt AC 23 ms 3700 KB
01-05.txt AC 23 ms 3572 KB
01-06.txt AC 22 ms 3700 KB
01-07.txt AC 21 ms 3572 KB
01-08.txt AC 22 ms 3700 KB
01-09.txt AC 22 ms 3572 KB
01-10.txt AC 23 ms 4084 KB
02-01.txt AC 351 ms 51704 KB
02-02.txt AC 632 ms 70256 KB
02-03.txt AC 337 ms 37756 KB
02-04.txt AC 483 ms 71632 KB
02-05.txt AC 570 ms 60888 KB
02-06.txt AC 488 ms 71236 KB
02-07.txt AC 563 ms 64308 KB
02-08.txt AC 481 ms 68480 KB
02-09.txt AC 590 ms 106928 KB
02-10.txt AC 412 ms 65304 KB
02-11.txt AC 403 ms 63136 KB
02-12.txt AC 434 ms 56452 KB
02-13.txt AC 434 ms 56856 KB
sample-01.txt AC 17 ms 3064 KB
sample-02.txt AC 18 ms 3064 KB