結果
問題 |
No.1637 Easy Tree Query
|
ユーザー |
|
提出日時 | 2021-08-24 23:57:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 354 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 28,416 KB |
最終ジャッジ日時 | 2024-11-15 13:54:21 |
合計ジャッジ時間 | 24,542 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 RE * 1 |
ソースコード
def dfs(x,p): cnt=1 for i in g[x]: if i!=p: cnt+=dfs(i,x) ans[x]=cnt return cnt n,q=map(int,input().split()) g=[[] for i in range(n+1)] for i in range(n-1): a,b=map(int,input().split()) g[a-1].append(b-1) g[b-1].append(a-1) ans=[0]*(n+1) dfs(0,-1) a=0 for i in range(q): p,x=map(int,input().split()) a+=ans[p-1]*x print(a)