結果
問題 |
No.1637 Easy Tree Query
|
ユーザー |
|
提出日時 | 2021-08-24 23:51:28 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 344 bytes |
コンパイル時間 | 729 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 28,288 KB |
最終ジャッジ日時 | 2024-11-15 13:45:02 |
合計ジャッジ時間 | 25,709 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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].append(b) g[b].append(a) ans=[0]*(n+1) dfs(1,0) a=0 for i in range(q): p,x=map(int,input().split()) a+=ans[p]*x print(a)