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;
const int maxn = 5e4 + 2;
vector<pair<int,int> > adj[maxn];
vector<tuple<int,int,int> > edge;
bool vis[maxn];
void dfs(int u,int &c){
if(!vis[u]){
vis[u] = true;
for(auto [v,w] : adj[u]){
if(w >= c){
dfs(v,c);
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n >> m;
for(int i=1;i<=m;i++){
int u,v,w;
cin >> u >> v >> w;
adj[u].emplace_back(v,w);
adj[v].emplace_back(u,w);
edge.emplace_back(u,v,w);
}
int q;
cin >> q;
while(q--){
int t,x,y;
cin >> t >> x >> y;
if(t == 1){
int u = get<0>(edge[x-1]);
int v = get<1>(edge[x-1]);
int w = get<2>(edge[x-1]);
int ux = lower_bound(adj[u].begin(),adj[u].end(),make_pair(v,w))-adj[u].begin();
int vx = lower_bound(adj[v].begin(),adj[v].end(),make_pair(u,w))-adj[v].begin();
edge[x-1] = make_tuple(u,v,y);
adj[u][ux].second = y;
adj[v][vx].second = y;
}else{
memset(vis,false,sizeof(vis));
dfs(x,y);
int r = 0;
for(int i=1;i<=n;i++){
r += vis[i];
}
cout << r << '\n';
}
}
}
Compilation message (stderr)
bridges.cpp: In function 'void dfs(int, int&)':
bridges.cpp:11:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
11 | for(auto [v,w] : adj[u]){
| ^
# | 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... |