This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |