제출 #1069676

#제출 시각아이디문제언어결과실행 시간메모리
1069676vjudge1다리 (APIO19_bridges)C++17
13 / 100
29 ms9080 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<long long, long long> #define pb push_back #define F first #define S second #define all(x) (x).begin(), (x).end() const ll N = 3e5 + 100; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll block = 350; ll n,m,q; ll c[N]; bool vs[N]; vector<pll>adj[N]; struct cmp{ bool operator()(const pll &a, const pll &b){ return a.S > b.S; } }; void sub1(){ for(int i = 1; i <= m;i++){ ll u,v,w; cin >> u >> v >> w; adj[u].pb({v, i}), adj[v].pb({u, i}); c[i] = w; } cin >> q; while(q--){ ll typ; cin >> typ; if(typ == 1){ ll x,y; cin >> x >> y; c[x] = y; } else{ ll s,w; cin >> s >> w; for(int i = 1; i <= n;i++) vs[i] = 0; vs[s] = 1; queue<ll>q; q.push(s); while(q.size()){ ll u = q.front();q.pop(); for(auto v : adj[u]){ if(vs[v.F] || w > c[v.S]) continue; vs[v.F] = 1; q.push(v.F); } } ll res = 0; for(int i = 1; i <= n;i++) if(vs[i]) res++; cout << res << "\n"; } } } void to_thic_cau(){ cin >> n >> m; if(max(n, m) <= 1000) sub1(); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll tc = 1; //cin >> tc; while(tc--) to_thic_cau(); }
#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...