Submission #1098269

#TimeUsernameProblemLanguageResultExecution timeMemory
1098269vjudge1Bridges (APIO19_bridges)C++17
13 / 100
3068 ms53368 KiB
#include <bits/stdc++.h> #define pb push_back #define int long long #define S second #define F first #define ahah ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); using namespace std; const int N = 1e6 + 7; const int MOD = 1e9 + 7; vector<vector<pair<int, int>>> g(N); vector<pair<int, int>> number(N); int x[N], y[N], w[N]; bool used[N]; set<int> st; void dfs(int v, int weight) { used[v] = true; st.insert(v); for (auto to : g[v]) { if (!used[to.F] and to.S >= weight) { dfs(to.F, weight); } } return; } signed main() { ahah int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> x[i] >> y[i] >> w[i]; g[x[i]].pb({y[i], w[i]}); g[y[i]].pb({x[i], w[i]}); number[i] = {g[x[i]].size() - 1, g[y[i]].size() - 1}; } int q; cin >> q; while (q--) { int t, s, weight; cin >> t >> s >> weight; if (t == 1) { int u = x[s], v = y[s]; g[u][number[s].F].S = weight; g[v][number[s].S].S = weight; } else { st.clear(); for(int i = 0 ; i <= n ; i++){ used[i]=false; } dfs(s, weight); cout << st.size() << "\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...