Submission #977690

#TimeUsernameProblemLanguageResultExecution timeMemory
977690ZHIRDILBILDIZBridges (APIO19_bridges)C++14
13 / 100
3055 ms20956 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> using namespace std; const int N = 5e4 + 10; set<pair<pii, int>> gr[N]; bool us[N]; vector<int> now; void dfs (int city, int w) { us[city] = 1; now.push_back(city); for (auto i : gr[city]) { if (us[i.fi.fi] || i.fi.se < w) continue; dfs(i.fi.fi, w); } } signed main () { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); int t = 1; // cin >> t; while (t--) { int n, m, q; cin >> n >> m; int u[m + 1], v[m + 1], w[m + 1]; for (int i = 1; i <= m; ++i) { cin >> u[i] >> v[i] >> w[i]; gr[u[i]].insert({{v[i], w[i]}, i}); gr[v[i]].insert({{u[i], w[i]}, i}); } cin >> q; while (q--) { int type; int l, r; cin >> type >> l >> r; if (type == 1) { gr[u[l]].erase({{v[l], w[l]}, l}); gr[v[l]].erase({{u[l], w[l]}, l}); w[l] = r; gr[u[l]].insert({{v[l], w[l]}, l}); gr[v[l]].insert({{u[l], w[l]}, l}); } else { now.clear(); dfs(l, r); for (int i : now) us[i] = 0; cout << now.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...