제출 #926537

#제출 시각아이디문제언어결과실행 시간메모리
926537Aiperiii다리 (APIO19_bridges)C++14
13 / 100
3081 ms10468 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb push_back using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n,m; cin>>n>>m; vector <int> u(m+1),v(m+1),w(m+1); for(int i=1;i<=m;i++){ cin>>u[i]>>v[i]>>w[i]; } int qu;cin>>qu; while(qu--){ int type,ver,x; cin>>type>>ver>>x; if(type==1)w[ver]=x; else{ vector <pair <int,int> > g[n+1]; for(int i=1;i<=m;i++){ g[u[i]].pb({v[i],w[i]}); g[v[i]].pb({u[i],w[i]}); } vector <int> vis(n+1); vis[ver]=1; int cnt=1; queue <int> q;q.push(ver); while(!q.empty()){ int v=q.front(); q.pop(); for(auto to : g[v]){ if(!vis[to.ff] && to.ss>=x){ vis[to.ff]=1; cnt++; q.push(to.ff); } } } cout<<cnt<<"\n"; } } } /* 3 4 1 2 5 2 3 2 3 1 4 2 3 8 5 2 1 5 1 4 1 2 2 5 1 1 1 2 3 2 */
#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...