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;
const int N=150050;
int n,m,q,u[N],v[N],w[N],ans,t,a,b;
bool vis[N];
vector<int> adj[N];
void dfs(int nde,int lim){
vis[nde]=1;
for (int i:adj[nde]){
if (i>0){
if (w[i]>=lim&&!vis[v[i]]) dfs(v[i],lim);
}else{
if (w[-i]>=lim&&!vis[u[-i]]) dfs(u[-i],lim);
}
}
}
int main(){
cin>>n>>m;
for (int i=1;i<=m;i++){
cin>>u[i]>>v[i]>>w[i];
adj[u[i]].push_back(i);
adj[v[i]].push_back(-i);
}
cin>>q;
while (q--){
cin>>t>>a>>b;
if (t==1){
w[a]=b;
continue;
}
for (int i=1;i<=n;i++) vis[i]=0;
dfs(a,b);
ans=0;
for (int i=1;i<=n;i++) ans+=vis[i];
cout<<ans<<"\n";
}
}
# | 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... |