제출 #252147

#제출 시각아이디문제언어결과실행 시간메모리
252147Erkhemkhuu다리 (APIO19_bridges)C++17
0 / 100
39 ms48764 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second const ll N = 1005; bool vis[N]; tuple <ll, ll, ll> brid[N]; vector <vector <ll> > adj(N); vector <ll> wp[N][N]; ll dfs(ll v, ll w) { ll ans = 1; vis[v] = true; for(auto &u: adj[v]) { if(vis[u]) continue; for(auto &x: wp[v][u]) if(w <= x) ans += dfs(u, w); } return ans; } int main() { ll n, m, i, v, u, w, q, t, l, r; cin >> n >> m; for(i = 0; i < m; i++) { cin >> v >> u >> w; v--; u--; adj[v].pb(u); adj[u].pb(v); wp[v][u].pb(w); wp[u][v].pb(w); brid[i] = {v, u, wp[v][u].size() - 1}; } cin >> q; while(q--) { cin >> t >> l >> r; l--; if(t == 1) { auto temp = brid[l]; ll x = get <0> (temp); ll y = get <1> (temp); ll z = get <2> (temp); wp[x][y][z] = wp[y][x][z] = r; } else { memset(vis, false, sizeof(vis)); cout << dfs(l, r) << "\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...