제출 #1031777

#제출 시각아이디문제언어결과실행 시간메모리
1031777Gangsta다리 (APIO19_bridges)C++14
0 / 100
477 ms9304 KiB
#include "bits/stdc++.h" #define ll long long int #define pb push_back #define pii pair<int,int> #define ff first #define ss second #define sz size() const int N = 5e4 + 1; using namespace std; int n, m, x[N], y[N], w[N], q, vis[N], ans; vector <pii> v[N]; void dfs(int nd, int wgh){ if(vis[nd]) return; ans++; vis[nd] = 1; for(auto i: v[nd]){ if(wgh <= i.ss) dfs(i.ff,wgh); } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for(int i = 1; i <= m; i++){ cin >> x[i] >> y[i] >> w[i]; v[x[i]].pb({y[i],w[i]}); v[y[i]].pb({x[i],w[i]}); } cin >> q; while(q--){ int t, a, b; cin >> t >> a >> b; if(t == 1){ for(int i = 0; i < (int)v[x[a]].sz; i++){ if(v[x[a]][i].ff == y[a] and v[x[a]][i].ss == w[a]){ v[x[a]][i].ss = b; break; } } } else{ ans = 0; for(int i = 1; i <= n; i++) vis[i] = 0; dfs(a,b); 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...