Submission #567810

#TimeUsernameProblemLanguageResultExecution timeMemory
5678108e7Bridges (APIO19_bridges)C++17
13 / 100
3069 ms11164 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T,class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 100005 #define pii pair<int, int> #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); const int inf = 1<<30; const int bs = 200; vector<pii> adj[maxn]; int wei[maxn]; pii ed[maxn]; bool vis[maxn]; void getans(int n, int wi, int &ans) { ans++; vis[n] = 1; for (auto [v, w]:adj[n]) { if (!vis[v] && wei[w] >= wi) { getans(v, wi, ans); } } } int main() { io int n, m; cin >> n >> m; for (int i = 0;i < m;i++) { int u, v, w; cin >> u >> v >> w; ed[i] = {u, v}; adj[u].push_back({v, i}); adj[v].push_back({u, i}); wei[i] = w; } int q; cin >> q; while (q--) { int type; cin >> type; if (type == 1) { int bi, ri; cin >> bi >> ri; bi--; wei[bi] = ri; } else { int s, w; cin >> s >> w; int ans = 0; for (int i = 1;i <= n;i++) vis[i] = 0; getans(s, w, ans); cout << ans << "\n"; } } } /* 7 6 1 2 4 1 3 5 2 4 2 2 5 1 3 6 7 3 7 3 5 2 3 3 1 4 3 2 3 5 2 2 2 2 1 6 */
#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...