AtCoder Beginner Contest 070

Submission #1508893

Source codeソースコード

n = int(input())

d = [0 for i in range(n+1)]
adj = [[] for i in range(n+1)]

def dfs(u, par):
    for p in adj[u]:
        v, w = map(int, p)
        # print(v, w)
        if v != par:
            d[v] = d[u]+w
            dfs(v, u)

edge = [list(map(int, input().split())) for i in range(n-1)]
q, k = map(int, input().split())
query = [list(map(int, input().split())) for i in range(q)]

for e in edge:
    adj[e[0]].append([e[1], e[2]])
    adj[e[1]].append([e[0], e[2]])
    
dfs(k, -1)

for p in query:
    print(d[p[0]]+d[p[1]])

Submission

Task問題 D - Transit Tree Path
User nameユーザ名 xuanquang1999
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 RE
Score得点 0
Source lengthソースコード長 558 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 0 / 400 sample_01.txt,sample_02.txt,sample_03.txt,subtask_1_1.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_16.txt,subtask_1_17.txt,subtask_1_18.txt,subtask_1_19.txt,subtask_1_2.txt,subtask_1_20.txt,subtask_1_21.txt,subtask_1_22.txt,subtask_1_23.txt,subtask_1_24.txt,subtask_1_25.txt,subtask_1_26.txt,subtask_1_27.txt,subtask_1_28.txt,subtask_1_3.txt,subtask_1_4.txt,subtask_1_5.txt,subtask_1_6.txt,subtask_1_7.txt,subtask_1_8.txt,subtask_1_9.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 16 ms 3064 KB
sample_02.txt AC 17 ms 3064 KB
sample_03.txt AC 17 ms 3064 KB
subtask_1_1.txt AC 17 ms 3064 KB
subtask_1_10.txt AC 261 ms 16048 KB
subtask_1_11.txt AC 19 ms 3188 KB
subtask_1_12.txt AC 38 ms 4212 KB
subtask_1_13.txt AC 94 ms 7184 KB
subtask_1_14.txt AC 17 ms 3064 KB
subtask_1_15.txt AC 47 ms 6084 KB
subtask_1_16.txt AC 1360 ms 82964 KB
subtask_1_17.txt AC 1329 ms 82900 KB
subtask_1_18.txt AC 1367 ms 83088 KB
subtask_1_19.txt AC 1381 ms 83108 KB
subtask_1_2.txt AC 25 ms 3824 KB
subtask_1_20.txt RE
subtask_1_21.txt RE
subtask_1_22.txt RE
subtask_1_23.txt RE
subtask_1_24.txt AC 1150 ms 79416 KB
subtask_1_25.txt AC 1112 ms 79420 KB
subtask_1_26.txt AC 1162 ms 79420 KB
subtask_1_27.txt AC 1159 ms 79416 KB
subtask_1_28.txt RE
subtask_1_3.txt AC 842 ms 58668 KB
subtask_1_4.txt AC 17 ms 3064 KB
subtask_1_5.txt AC 356 ms 24764 KB
subtask_1_6.txt AC 115 ms 10376 KB
subtask_1_7.txt AC 301 ms 20232 KB
subtask_1_8.txt AC 17 ms 3064 KB
subtask_1_9.txt AC 968 ms 65716 KB