結果
| 問題 | No.1103 Directed Length Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-06 00:52:20 |
| 言語 | Kuin (KuinC++ v.2021.9.17) |
| 結果 |
AC
|
| 実行時間 | 1,208 ms / 3,000 ms |
| コード長 | 1,091 bytes |
| 記録 | |
| コンパイル時間 | 1,702 ms |
| コンパイル使用メモリ | 167,336 KB |
| 実行使用メモリ | 316,416 KB |
| 最終ジャッジ日時 | 2026-04-05 17:34:42 |
| 合計ジャッジ時間 | 13,322 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
コンパイルメッセージ
out.cpp:676:14: warning: first argument in call to 'memset' is a pointer to non-trivially copyable type 'std::shared_ptr<k_ap>' [-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<k_ap>>>>::operator()<long>' requested here
688 | return newArraysRec_<T>()(std::forward<A>(a)...);
| ^
out.cpp:1647:11: note: in instantiation of function template specialization 'newArrays_<std::shared_ptr<Array_<std::shared_ptr<k_ap>>>, long>' requested here
1647 | (k_ao) = (newArrays_<type_(Array_<type_(k_ap)>)>((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.
ソースコード
func main()
const mod: int :: 1000000007
class Node()
+var parent: Node
+var children: list<Node>
+var depth: int
+var size: int
*func ctor()
do me.parent :: null
do me.children :: #list<Node>
end func
+func update()
if(me.parent <>& null)
do me.depth :: me.parent.depth + 1
end if
do me.children.head()
for i(0, ^me.children - 1)
var child: Node :: me.children.get()
do child.update()
do me.size :+ child.size
do me.children.next()
end for
do me.size :+ 1
end func
end class
var n: int :: cui@inputInt()
var nodes: []Node :: #[n]Node
for i(0, n - 1)
do nodes[i] :: #Node
end for
for i(0, n - 2)
var a: int :: cui@inputInt() - 1
var b: int :: cui@inputInt() - 1
do nodes[a].children.add(nodes[b])
do nodes[b].parent :: nodes[a]
end for
var root: Node
for i(0, n - 1)
if(nodes[i].parent =& null)
do root :: nodes[i]
break i
end if
end for
do root.update()
var ans: int :: 0
for i(0, n - 1)
do ans :+ nodes[i].depth * nodes[i].size
do ans :% mod
end for
do cui@print("\{ans}\n")
end func