This documentation is automatically generated by competitive-verifier/competitive-verifier
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/tree_path_composite_sum
#include <iostream>
#include <utility>
#include <vector>
#include "math/modint.hpp"
#include "tree/rerooting.hpp"
using Mint = modint998;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
return is >> p.first >> p.second;
}
struct Monoid {
using T = std::pair<Mint, Mint>;
using value_type = T;
static constexpr T id() { return T(); }
static constexpr T op(const T &lhs, const T &rhs) {
return {lhs.first + rhs.first, lhs.second + rhs.second};
}
template <class U>
static constexpr T f(const T &v, U u) {
return {u.first * v.first + u.second * v.second, v.second};
}
template <class U>
static constexpr T g(const T &v, U u) {
return {v.first + u, v.second + 1};
}
};
int main(void) {
int n;
std::cin >> n;
std::vector<Mint> a(n);
for (auto &e : a) std::cin >> e;
Graph<std::pair<Mint, Mint>> g(n);
g.input_edges(n - 1, 0);
ReRooting<Monoid, std::pair<Mint, Mint>, Mint> rr(g, a);
std::vector<Mint> ans;
for (int i = 0; i < n; ++i) ans.emplace_back(rr[i].first);
for (int i = 0; i < (int)ans.size(); ++i)
std::cout << ans[i] << (i == (int)ans.size() - 1 ? '\n' : ' ');
return 0;
}
Traceback (most recent call last):
File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/resolver.py", line 291, in resolve
bundled_code = language.bundle(path, basedir=basedir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus.py", line 242, in bundle
bundler.update(path)
File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 479, in update
self._resolve(pathlib.Path(included), included_from=path)
File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 286, in _resolve
raise BundleErrorAt(path, -1, "no such header")
competitive_verifier.oj.verify.languages.cplusplus_bundle.BundleErrorAt: math/modint.hpp: line -1: no such header
| Env | Name | Status | Elapsed | Memory |
|---|---|---|---|---|
| g++ | example_00 |
|
3 ms | 4 MB |
| g++ | example_01 |
|
2 ms | 3 MB |
| g++ | n_hundreds_00 |
|
3 ms | 4 MB |
| g++ | n_hundreds_01 |
|
3 ms | 4 MB |
| g++ | tiny_00 |
|
2 ms | 3 MB |
| g++ | tiny_01 |
|
2 ms | 4 MB |
| g++ | typical_tree_max_00 |
|
527 ms | 68 MB |
| g++ | typical_tree_max_01 |
|
427 ms | 49 MB |
| g++ | typical_tree_max_02 |
|
453 ms | 48 MB |
| g++ | typical_tree_max_03 |
|
459 ms | 47 MB |
| g++ | typical_tree_max_04 |
|
506 ms | 63 MB |
| g++ | typical_tree_max_05 |
|
441 ms | 60 MB |
| g++ | typical_tree_max_06 |
|
466 ms | 60 MB |
| g++ | typical_tree_max_07 |
|
521 ms | 66 MB |
| g++ | typical_tree_max_08 |
|
437 ms | 47 MB |
| g++ | typical_tree_max_09 |
|
436 ms | 47 MB |