結果
| 問題 | No.1637 Easy Tree Query |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-17 12:00:10 |
| 言語 | Kuin (KuinC++ v.2021.9.17) |
| 結果 |
AC
|
| 実行時間 | 227 ms / 2,000 ms |
| コード長 | 857 bytes |
| 記録 | |
| コンパイル時間 | 4,180 ms |
| コンパイル使用メモリ | 165,428 KB |
| 実行使用メモリ | 29,824 KB |
| 最終ジャッジ日時 | 2026-03-25 15:43:35 |
| 合計ジャッジ時間 | 11,697 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 33 |
コンパイルメッセージ
out.cpp:676:14: warning: first argument in call to 'memset' is a pointer to non-trivially copyable type 'std::shared_ptr<List_<long>>' [-Wnontrivial-memcall]
676 | memset(r->B, 0, sizeof(T) * static_cast<std::size_t>(h + bufLen_<T>()));
| ^
out.cpp:688:9: note: in instantiation of function template specialization 'newArraysRec_<std::shared_ptr<Array_<std::shared_ptr<List_<long>>>>>::operator()<long>' requested here
688 | return newArraysRec_<T>()(std::forward<A>(a)...);
| ^
out.cpp:1627:11: note: in instantiation of function template specialization 'newArrays_<std::shared_ptr<Array_<std::shared_ptr<List_<long>>>>, long>' requested here
1627 | (k_ap) = (newArrays_<type_(Array_<type_(List_<int64_t>)>)>((k_am)));
| ^
out.cpp:676:14: note: explicitly cast the pointer to silence this warning
676 | memset(r->B, 0, sizeof(T) * static_cast<std::size_t>(h + bufLen_<T>()));
| ^
| (void*)
1 warning generated.
ソースコード
var cnts: []int
func main()
var n: int :: cui@inputInt()
var q: int :: cui@inputInt()
var g: []list<int> :: #[n]list<int>
for i(0, n - 1)
do g[i] :: #list<int>
end for
for(1, n - 1)
var a: int :: cui@inputInt() - 1
var b: int :: cui@inputInt() - 1
do g[a].add(b)
do g[b].add(a)
end for
do @cnts :: #[n]int
do bfs(g, 0, -1)
var ans: int :: 0
for(1, q)
var p: int :: cui@inputInt() - 1
var x: int :: cui@inputInt()
do ans :+ @cnts[p] * x
do cui@print("\{ans}\n")
end for
func bfs(g: []list<int>, current: int, parent: int): int
var gc: list<int> :: g[current]
do gc.head()
var cnt: int :: 1
for i(0, ^gc - 1)
var neighbor: int :: gc.get()
do gc.next()
if(neighbor = parent)
skip i
end if
do cnt :+ bfs(g, neighbor, current)
end for
do @cnts[current] :: cnt
ret cnt
end func
end func