Submission #240127

#TimeUsernameProblemLanguageResultExecution timeMemory
240127wiwihoBridges (APIO19_bridges)C++14
13 / 100
3094 ms8824 KiB
//#define NDEBUG #include <bits/stdc++.h> #include <bits/extc++.h> #define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define iter(a) a.begin(), a.end() #define riter(a) a.rbegin(), a.rend() #define lsort(a) sort(iter(a)) #define gsort(a) sort(riter(a)) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define pf(a) push_front(a) #define pob pop_back() #define pof pop_front() #define mp(a, b) make_pair(a, b) #define F first #define S second #define mt make_tuple #define gt(t, i) get<i>(t) #define iceil(a, b) ((a + b - 1) / b) #define tomax(a, b) (a = max(a, b)) #define printv(a, b) {bool pvaspace=false; \ for(auto pva : a){ \ if(pvaspace) b << " "; pvaspace=true;\ b << pva;\ }\ b << "\n";} //#define TEST using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef long double ld; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<ld, ld>; using tiii = tuple<int, int, int>; const ll MOD = 1000000007; const ll MAX = 2147483647; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } vector<int> w; vector<vector<pii>> g; vector<bool> vst; void dfs(int now, int wl){ vst[now] = true; for(pii i : g[now]){ if(w[i.S] < wl || vst[i.F]) continue; dfs(i.F, wl); } } int main(){ StarBurstStream int n, m; cin >> n >> m; g.resize(n + 1); w.resize(m + 1); for(int i = 1; i <= m; i++){ int u, v; cin >> u >> v; cin >> w[i]; g[u].eb(mp(v, i)); g[v].eb(mp(u, i)); } int q; cin >> q; while(q--){ int t; cin >> t; if(t == 1){ int b, r; cin >> b >> r; w[b] = r; } else{ int s, wl; cin >> s >> wl; vst.clear(); vst.resize(n + 1); dfs(s, wl); int ans = 0; for(bool i : vst) ans += i; cout << ans << "\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...