Submission #690533

#TimeUsernameProblemLanguageResultExecution timeMemory
690533thinh1711Bridges (APIO19_bridges)C++17
13 / 100
3090 ms7428 KiB
#include <bits/stdc++.h> #define reu(i,a,b) for (int i=a;i<=b;++i) #define pb push_back using namespace std; int n,m; const int mx=100002; int bridge[mx]; vector<pair<int , int> > ke[mx]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>m; reu(i,1,m){ int u,v,d; cin>>u>>v; ke[u].pb({v,i}); ke[v].pb({u,i}); cin>>d; bridge[i]=d; } int q; cin>>q; reu(i,1,q) { int typ; cin>>typ; if (typ==1){ int v,w; cin>>v>>w; bridge[v]=w; } else { bool is[mx]; int cnt=1; memset(is,true,sizeof(is)); int w,s; cin>>s>>w; is[s]=false; queue<int> q; q.push(s); while (!q.empty()){ int h=q.front(); q.pop(); for (auto x:ke[h]) if (is[x.first]==true) if (bridge[x.second]>=w){ is[x.first]=false; q.push(x.first); ++cnt; } } cout<<cnt<<"\n"; } } return 0; }
#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...