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 int long long
const int mxN = 1005, mxM = 100005;
multiset<pair<int,int>> graph[mxN];
tuple<int,int,int> bridge[mxM];
bool seen[mxN];
int cnt;
void dfs(int x, int weight) {
if(seen[x]) return;
cnt++, seen[x] = 1;
for(auto edge : graph[x]) {
if(edge.first < weight) continue;
dfs(edge.second, weight);
}
}
signed main() {
//freopen("bridge.in", "r", stdin);
//freopen("bridge.out", "w", stdout);
int n, m; cin >> n >> m;
if(n > 1000) exit(-1);
for(int i = 1; i <= m; i++) {
int u, v, d; cin >> u >> v >> d;
graph[u].insert({d,v});
graph[v].insert({d,u});
bridge[i] = {u,v,d};
}
int q; cin >> q;
for(int g = 0; g < q; g++) {
int t; cin >> t;
if(t==1) {
int b, r; cin >> b >> r;
int u,v,d; tie(u,v,d) = bridge[b];
graph[u].erase(graph[u].find({d,v}));
graph[v].erase(graph[v].find({d,u}));
graph[u].insert({r,v});
graph[v].insert({r,u});
bridge[b] = {u,v,r};
} else {
memset(seen, 0, sizeof seen);
cnt = 0;
int s, w; cin >> s >> w;
dfs(s,w);
cout << cnt << '\n';
}
}
}
# | 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... |