제출 #973077

#제출 시각아이디문제언어결과실행 시간메모리
973077Unforgettablepl다리 (APIO19_bridges)C++17
13 / 100
51 ms4956 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define f first #define s second bool visited[1001]; vector<int> adj[1001]; pair<pair<int,int>,int> edges[1001]; int ans; void dfs(int x,int wt){ if(visited[x])return; visited[x]=true; ans++; for(int&i:adj[x]){ if(edges[i].s<wt)continue; dfs(edges[i].f.f,wt); dfs(edges[i].f.s,wt); } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,m; cin >> n >> m; for(int i=1;i<=m;i++){ int a,b,c;cin>>a>>b>>c; edges[i] = {{a,b},c}; adj[a].emplace_back(i); adj[b].emplace_back(i); } int q; cin >> q; for(int i=1;i<=q;i++){ int type,a,b;cin>>type>>a>>b; if(type==1){ edges[a].s = b; } else { for(bool&x:visited)x=false; ans = 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...