Submission #287479
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 tg=g[:] for e in tg: if e[0]==now: g.remove(e) s+=dfs(e[1]) tg=g[:] for e in tg: if e[1]==now: g.remove(e) s+=dfs(e[0]) if (s>0 or takara[now-1]==1) and now!=x: s+=1 return s print dfs(x)*2 # print g
Submission Info
Submission Time | |
---|---|
Task | B - ツリーグラフ |
User | richard |
Language | Python (2.7.3) |
Score | 100 |
Code Size | 514 Byte |
Status | AC |
Exec Time | 57 ms |
Memory | 3500 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
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 | 49 ms | 3388 KB |
subtask0_sample_02.txt | AC | 53 ms | 3392 KB |
subtask1_line01.txt | AC | 55 ms | 3388 KB |
subtask1_line02.txt | AC | 53 ms | 3324 KB |
subtask1_line03.txt | AC | 57 ms | 3380 KB |
subtask1_line04.txt | AC | 52 ms | 3496 KB |
subtask1_line05.txt | AC | 51 ms | 3496 KB |
subtask1_line06.txt | AC | 51 ms | 3500 KB |
subtask1_random01.txt | AC | 51 ms | 3384 KB |
subtask1_random02.txt | AC | 50 ms | 3384 KB |
subtask1_random03.txt | AC | 51 ms | 3392 KB |
subtask1_random04.txt | AC | 51 ms | 3388 KB |
subtask1_random05.txt | AC | 53 ms | 3392 KB |
subtask1_random06.txt | AC | 56 ms | 3308 KB |
subtask1_random07.txt | AC | 50 ms | 3308 KB |
subtask1_random08.txt | AC | 55 ms | 3304 KB |
subtask1_special01.txt | AC | 52 ms | 3384 KB |
subtask1_special02.txt | AC | 51 ms | 3380 KB |
subtask1_special03.txt | AC | 48 ms | 3376 KB |
subtask1_special04.txt | AC | 50 ms | 3376 KB |