# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
641294 | Tenis0206 | Traffickers (RMI18_traffickers) | C++11 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void get_w(int nod, int dad = 0)
{
w[nod] = 1;
for(auto it : G[nod])
{
if(it==dad)
{
continue;
}
get_w(it,nod);
w[nod] += w[it];
t[it] = nod;
if(w[it] > w[Max[nod]])
{
Max[nod] = it;
}
}
}
void get_paths(int nod, int dad = 0, int level = 1)
{
poz[nod] = (++cnt);
l[nod] = paths;
if(G[nod].size()==1 && nod!=1)
{
return;
}
get_paths(Max[nod],nod,level+1);
for(auto it : G[nod])
{
if(it==dad || it==Max[nod])
{
continue;
}
++paths;
c[paths] = it;
lvl[paths] = level + 1;
get_paths(it,nod,level+1);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
int x,y;
cin>>x>>y;
G[x].push_back(y);
G[y].push_back(x);
}
get_w(1);
get_paths(1);
cin>>k;
for(int i=1;i<=n;i++)
{
int x,y;
cin>>x>>y;
add_traficker(x,y);
}
cin>>q;
for(int i=1;i<=q;i++)
{
int tip;
cin>>tip;
if(tip==1)
{
int x,y;
cin>>x>>y;
add_traficker(x,y);
}
else if(tip==2)
{
int x,y;
cin>>x>>y;
remove_traficker(x,y);
}
else
{
int x,y,t1,t2;
cin>>x>>y>>t1>>t2;
cout<<query_arb(t2,)
}
}
return 0;
}