Submission #167549

#TimeUsernameProblemLanguageResultExecution timeMemory
167549qkxwsmBridges (APIO19_bridges)C++14
13 / 100
3045 ms11496 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() #define MAXN 100013 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N, M, Q; pair<pii, int> edge[MAXN]; vi edges[MAXN]; pair<pii, int> quer[MAXN]; bitset<MAXN> vis; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); cerr << fixed << setprecision(4); cin >> N >> M; FOR(i, 0, M) { int u, v, d; cin >> u >> v >> d; u--; v--; edge[i] = {{u, v}, d}; edges[u].PB(i); edges[v].PB(i); } cin >> Q; FOR(i, 0, Q) { cin >> quer[i].se >> quer[i].fi.fi >> quer[i].fi.se; quer[i].fi.fi--; } FOR(i, 0, Q) { int idx = quer[i].fi.fi, val = quer[i].fi.se; if (quer[i].se == 1) { edge[idx].se = val; } else { vis.reset(); vis[idx] = true; vi q; q.PB(idx); while(!q.empty()) { int u = q.back(); q.pop_back(); for (int eid : edges[u]) { int v = edge[eid].fi.fi ^ edge[eid].fi.se ^ u; if (edge[eid].se >= val && !vis[v]) { vis[v] = true; q.PB(v); } } } cout << vis.count() << '\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...