Submission #335142

#TimeUsernameProblemLanguageResultExecution timeMemory
335142nicholaskBridges (APIO19_bridges)C++14
13 / 100
3071 ms6712 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; tuple <int,int,int> g[m]; for (int i=0; i<m; i++) cin>>get<0>(g[i])>>get<1>(g[i])>>get<2>(g[i]); int q; cin>>q; while (q--){ int t,x,y; cin>>t>>x>>y; if (t==1) get<2>(g[x-1])=y; else { vector <int> v[n+1]; for (int i=0; i<m; i++){ if (get<2>(g[i])<y) continue; v[get<0>(g[i])].push_back(get<1>(g[i])); v[get<1>(g[i])].push_back(get<0>(g[i])); } bool visited[n+1]={}; queue <int> q; q.push(x); visited[x]=1; while (!q.empty()){ int f=q.front(); q.pop(); for (auto&i:v[f]){ if (visited[i]) continue; q.push(i); visited[i]=1; } } int cnt=0; for (int i=1; i<=n; i++){ if (visited[i]) cnt++; } cout<<cnt<<endl; } } }
#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...