Submission #597537

#TimeUsernameProblemLanguageResultExecution timeMemory
597537WongChun1234Bridges (APIO19_bridges)C++14
13 / 100
3078 ms12236 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...