Submission #769691

#TimeUsernameProblemLanguageResultExecution timeMemory
769691boyliguanhanBridges (APIO19_bridges)C++17
13 / 100
3084 ms10332 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize(2) #define MAXN 100100 int n,m,q, w[MAXN]; vector<pair<int, int>> adj[MAXN]; bool b[500100]; int ans = 0; void dfs(int n, int wl) { if(b[n]) return; b[n] = 1, ans+=1; for(auto i: adj[n]) if(w[i.second] >= wl) dfs(i.first, wl); } signed main() { cin >> n >> m; for(int i = 0; i < m; i++) { int a,b; cin >> a >> b >> w[i]; adj[a].push_back({b,i}); adj[b].push_back({a,i}); } cin >> q; for(int i = 0; i < q; i++) { int t,s,wl; cin >> t >> s >> wl; if(t-1) { ans = 0; memset(b, 0, sizeof b); dfs(s, wl); cout << ans << '\n'; } else { w[s-1] = wl; } } }
#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...