Submission #287173


Source Code Expand

Copy
n,x = map(int,raw_input().split())
takara = map(int,raw_input().split())
g=[]
for i in xrange(n-1):
    g.append(map(int,raw_input().split()))

# print g

def dfs(now):

    s=0

    for e in g:
        if e[0]==now:
            s+=dfs(e[1])

    if (s>0 or takara[now-1]==1) and now!=x:
        s+=1


    return s

print dfs(x)*2

Submission Info

Submission Time
Task B - ツリーグラフ
User richard
Language Python (2.7.3)
Score 0
Code Size 357 Byte
Status WA
Exec Time 53 ms
Memory 3396 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 9
WA × 11
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_line01.txt, subtask1_line02.txt, subtask1_line03.txt, subtask1_line04.txt, subtask1_line05.txt, subtask1_line06.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt, subtask1_special01.txt, subtask1_special02.txt, subtask1_special03.txt, subtask1_special04.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 50 ms 3380 KB
subtask0_sample_02.txt AC 51 ms 3380 KB
subtask1_line01.txt AC 50 ms 3388 KB
subtask1_line02.txt AC 52 ms 3380 KB
subtask1_line03.txt AC 50 ms 3396 KB
subtask1_line04.txt WA 52 ms 3388 KB
subtask1_line05.txt WA 52 ms 3372 KB
subtask1_line06.txt AC 51 ms 3384 KB
subtask1_random01.txt WA 51 ms 3388 KB
subtask1_random02.txt WA 51 ms 3328 KB
subtask1_random03.txt WA 49 ms 3380 KB
subtask1_random04.txt WA 52 ms 3380 KB
subtask1_random05.txt WA 51 ms 3384 KB
subtask1_random06.txt WA 50 ms 3380 KB
subtask1_random07.txt WA 48 ms 3380 KB
subtask1_random08.txt WA 52 ms 3384 KB
subtask1_special01.txt AC 52 ms 3388 KB
subtask1_special02.txt AC 52 ms 3392 KB
subtask1_special03.txt AC 53 ms 3380 KB
subtask1_special04.txt WA 52 ms 3384 KB