Submission #978559

#TimeUsernameProblemLanguageResultExecution timeMemory
978559akacool445kBridges (APIO19_bridges)C++14
0 / 100
3022 ms15992 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second // #define int long long const long long mod = 1e9 + 7; const long long shrek = (1 << 30); const int gay = 5e4 + 10; set<pair<int, int>> adj[gay]; bool vis[gay]; vector<int> cur; void dfs(int x, int w) { vis[x] = 1; cur.push_back(x); for(auto y : adj[x]) { if(vis[y.ff] == 1 || y.ss < w) { continue; } dfs(y.ff, w); } } signed main() { int n, m, q; cin >> n >> m; int u[m + 5], v[m + 5], w[m + 5]; for(int i = 1; i <= m; i++) { cin >> u[i] >> v[i] >> w[i]; adj[u[i]].insert({v[i], w[i]}); adj[v[i]].insert({u[i], w[i]}); } cin >> q; while(q--) { int c, st, f; cin >> c >> st >> f; if(c == 1) { adj[u[st]].erase(adj[u[st]].find({v[st], w[st]})); adj[v[st]].erase(adj[u[st]].find({u[st], w[st]})); w[st] = f; adj[u[st]].insert({v[st], w[st]}); adj[v[st]].insert({u[st], w[st]}); } else { cur.clear(); dfs(st, f); for(int x : cur) vis[x] = 0; cout << cur.size() << '\n'; } } return 0; }
#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...