Submission #978980

#TimeUsernameProblemLanguageResultExecution timeMemory
978980Halym2007Bridges (APIO19_bridges)C++17
13 / 100
3052 ms10116 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define pii pair <int, int> #define sz size() const int N = 5e4 + 5; pii val[N]; int l[N], r[N], w[N], vis[N]; vector <pii> v[N]; void dfs (int x, int y) { vis[x] = 1; for (pii i : v[x]) { if (vis[i.ff]) continue; if (y <= i.ss) dfs (i.ff, y); } } int main () { // freopen ("input.txt", "r", stdin); int n, m, q; cin >> n >> m; for (int i = 1; i <= m; ++i) { cin >> l[i] >> r[i] >> w[i]; val[i] = {(int)v[l[i]].sz, (int)v[r[i]].sz}; v[l[i]].pb({r[i], w[i]}); v[r[i]].pb({l[i], w[i]}); } cin >> q; while ( q-- ) { int query, x, y; cin >> query >> x >> y; // cout << "--> " << query << " " << x << " " << y << "\n"; if (query == 1) { pii pos = val[x]; v[l[x]][pos.ff].ss = y; v[r[x]][pos.ss].ss = y; } else { dfs (x, y); int jog = 0; for (int i = 1; i <= n; ++i) { if (vis[i]) jog++; vis[i] = 0; } cout << jog << "\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...