Submission #261973

#TimeUsernameProblemLanguageResultExecution timeMemory
261973hanagasumiBridges (APIO19_bridges)C++17
13 / 100
3058 ms10796 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <deque> #include <map> #include <set> #include <complex> #include <string> #include <unordered_map> #include <unordered_set> #include <random> #define ft first #define sc second #define pb push_back #define len(v) (int)v.size() #define int ll using namespace std; typedef long long ll; typedef long double ld; struct edge { int v, u, w; }; signed main() { #ifdef PC freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, q; cin >> n >> m; vector<edge> e; vector<vector<int>> g(n); for (int i = 0; i < m; i++) { int a, b, w; cin >> a >> b >> w; a--, b--; g[a].pb(len(e)); e.pb({a, b, w}); g[b].pb(len(e)); e.pb({b, a, w}); } cin >> q; while(q--) { int type, id, w; cin >> type >> id >> w; id--; if(type == 1) { e[2 * id].w = w; e[2 * id + 1].w = w; continue; } vector<bool> used(n, 0); deque<int> q; used[id] = 1; q.pb(id); while(len(q)) { auto now = q.front(); q.pop_front(); for (auto i : g[now]) { auto x = e[i]; if(used[x.u] || x.w < w) continue; used[x.u] = 1; q.pb(x.u); } } int ans = 0; for (int i = 0; i < n; i++) { if(used[i]) ans++; } cout << ans << '\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...