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"
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
#define sz size()
const int N = 5e4 + 1;
using namespace std;
int n, m, x[N], y[N], w[N], q, vis[N], ans;
vector <pii> v[N];
void dfs(int nd, int wgh){
if(vis[nd]) return;
ans++;
vis[nd] = 1;
for(auto i: v[nd]){
if(wgh <= i.ss) dfs(i.ff,wgh);
}
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
for(int i = 1; i <= m; i++){
cin >> x[i] >> y[i] >> w[i];
v[x[i]].pb({y[i],w[i]});
v[y[i]].pb({x[i],w[i]});
}
cin >> q;
while(q--){
int t, a, b;
cin >> t >> a >> b;
if(t == 1){
for(int i = 0; i < v[x[a]].sz; i++){
if(v[x[a]][i].ff == y[a] and v[x[a]][i].ss == w[a]){
v[x[a]][i].ss = b;
break;
}
}
}
else{
ans = 0;
for(int i = 1; i <= n; i++) vis[i] = 0;
dfs(a,b);
cout << ans << '\n';
}
}
}
Compilation message (stderr)
bridges.cpp: In function 'int main()':
bridges.cpp:39:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i = 0; i < v[x[a]].sz; i++){
| ^
# | 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... |