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;
vector<pair<int,int> >v[100005];
int w[100005];
int vis[100005];
int dfs(int x,int wc){
vis[x]=1;
int sz=1;
for(auto e:v[x]){
if(w[e.second]>=wc&&vis[e.first]==0){
sz+=dfs(e.first,wc);
}
}
return sz;
}
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=m;i++){
int a,b,c;
cin>>a>>b>>c;
v[a].push_back({b,i});
v[b].push_back({a,i});
w[i]=c;
}
int q;
cin>>q;
while(q--){
int t;
cin>>t;
if(t==1){
int x,r;
cin>>x>>r;
w[x]=r;
}else{
int s,w;
cin>>s>>w;
cout<<dfs(s,w)<<"\n";
for(int i=1;i<=n;i++)vis[i]=0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |