# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
337254 | impri | Bridges (APIO19_bridges) | C++14 | 3093 ms | 9264 KiB |
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;
vector<pair<int,int> >graph[50001];
int ds[100001];
int visited[100001];
void dfs(int w,int cur){
visited[cur]=1;
for(int i=0;i<graph[cur].size();i++){
if(!visited[graph[cur][i].first] && ds[graph[cur][i].second]>=w){
dfs(w,graph[cur][i].first);
}
}
}
int main(){
int n,m;
cin >> n >> m;
for(int i=1;i<=m;i++){
int u,v,d;
cin >> u >> v >> d;
graph[u].push_back({v,i});
graph[v].push_back({u,i});
ds[i]=d;
}
int q;
cin >> q;
for(int i=1;i<=q;i++){
int t,a,b;
cin >> t >> a >> b;
if(t==1){
ds[a]=b;
}
else{
memset(visited,0,sizeof(visited));
dfs(b,a);
int res=0;
for(int j=1;j<=n;j++){
if(visited[j])res++;
}
cout << res << '\n';
}
}
}
Compilation message (stderr)
# | 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... |