Submission #139632

#TimeUsernameProblemLanguageResultExecution timeMemory
139632FedericoSBridges (APIO19_bridges)C++14
13 / 100
3053 ms24856 KiB
#include <iostream> #include <vector> #include <map> using namespace std; typedef pair<int,int> pii; typedef pair<int,pii> pip; int N,M; int t,x,y,z; vector<pii> grafo[50005]; int Q; map<pii,int> S; map<int,int> W; int ans; bool V[50005]; void DFS(int k){ if(V[k]) return; V[k]=true; ans++; for(pii f:grafo[k]) if(W[f.second]>=y) DFS(f.first); } int main(){ cin>>N>>M; for(int i=0;i<M;i++){ cin>>x>>y>>z; grafo[x].push_back({y,i+1}); grafo[y].push_back({x,i+1}); W[i+1]=z; S[{x,y}]=i+1; S[{y,x}]=i+1; } cin>>Q; while(Q--){ cin>>t>>x>>y; if(t==1) W[x]=y; else{ for(int i=1;i<N+1;i++) V[i]=false; ans=0; DFS(x); 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...