Submission #1031766

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