This documentation is automatically generated by online-judge-tools/verification-helper
// verification-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0367
#include <bits/stdc++.h>
using namespace std;
#define call_from_test
#include "../../linkcuttree/base.cpp"
#include "../../linkcuttree/path.cpp"
#undef call_from_test
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
using ll = long long;
int n,k;
cin>>n>>k;
using T = tuple<ll, ll, ll>;
vector<ll> ws(n,0);
vector< unordered_map<ll, ll> > m(n);
auto mget=[&](ll a,ll b){
if(!m[a].count(b)) return 0LL;
ll res=ws[a]+ws[b]+m[a][b];
if(res%k) return res;
return 0LL;
};
auto f=[&](T a,T b){
ll al,ar,av;
tie(al,ar,av)=a;
ll bl,br,bv;
tie(bl,br,bv)=b;
return T(al,br,av+bv+mget(ar,bl));
};
auto g=[&](T a,ll){return a;};
auto h=[&](ll a,ll){return a;};
auto s=[&](T a){
ll al,ar,av;
tie(al,ar,av)=a;
return T(ar,al,av);
};
using Node = NodeBase<T, ll>;
constexpr size_t LIM = 1e6;
using LCT = Path<Node, LIM>;
LCT lct(f,g,h,s,0);
for(int i=0;i<n;i++) lct.create(T(i,i,0));
for(int i=0;i<n-1;i++){
int a,b,c;
cin>>a>>b>>c;
lct.evert(lct[b]);
lct.link(lct[a],lct[b]);
m[a][b]=m[b][a]=c;
}
int q;
cin>>q;
for(int i=0;i<q;i++){
string op;
cin>>op;
if(op=="add"){
int x,d;
cin>>x>>d;
lct.expose(lct[x]);
ws[x]+=d;
lct.pushup(lct[x]);
}
if(op=="send"){
int s,t;
cin>>s>>t;
lct.evert(lct[s]);
cout<<get<2>(lct.query(lct[t]))<<"\n";
}
}
cout<<flush;
return 0;
}
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
bundler.update(path)
File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
self.update(self._resolve(pathlib.Path(included), included_from=path))
File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 400, in update
raise BundleErrorAt(path, i + 1, "unable to process #include in #if / #ifdef / #ifndef other than include guards")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: linkcuttree/path.cpp: line 6: unable to process #include in #if / #ifdef / #ifndef other than include guards