제출 #983535

#제출 시각아이디문제언어결과실행 시간메모리
983535horezushol다리 (APIO19_bridges)C++14
13 / 100
168 ms1372 KiB
#include<bits/stdc++.h> #define len(x) ((x).size()) using namespace std; using ll = long long; const char nl = '\n'; const ll N = 2000; ll n, m, q; multiset<pair<ll, pair<ll, ll>>> g[N]; ll res = 0; bool visited[N]; void dfs(ll x, ll w) { visited[x] = true; res ++; for (auto el : g[x]) { if (!visited[el.first] && w <= el.second.first) { dfs(el.first, w); } } } void rout() { for (ll i = 1; i <= n; i ++) { cout << i << ": "; for (auto el : g[i]) { cout << "{" << el.first << ", " << el.second.first << ", " << el.second.second << "} "; } cout << nl; } cout << nl << nl; } void solve() { cin >> n >> m; for (ll i = 0, br = 1; i < m; i ++, br ++) { ll u, v, w; cin >> u >> v >> w; g[u].insert({v, {w, br}}); g[v].insert({u, {w, br}}); } ll q; cin >> q; while (q --) { ll t; cin >> t; if (t == 1) { ll b, r; cin >> b >> r; for (ll i = 1; i <= n; i ++) { for (auto el : g[i]) { if (el.second.second == b) { auto it = g[i].find(el); g[i].insert({el.first, {r, el.second.second}}); g[i].erase(it); break; } } } // rout(); } else { ll s, w; cin >> s >> w; dfs(s, w); // cout << s << " " << w << " "; cout << res << nl; // rout(); for (ll i = 0; i <= n; i ++) { visited[i] = false; } res = 0; } } } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll tst = 1; // cin >> tst; while (tst --) { solve(); cout << nl; } }
#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...