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;
int main(){
int n,m;
cin>>n>>m;
tuple <int,int,int> g[m];
for (int i=0; i<m; i++) cin>>get<0>(g[i])>>get<1>(g[i])>>get<2>(g[i]);
int q;
cin>>q;
while (q--){
int t,x,y;
cin>>t>>x>>y;
if (t==1) get<2>(g[x-1])=y;
else {
vector <int> v[n+1];
for (int i=0; i<m; i++){
if (get<2>(g[i])<y) continue;
v[get<0>(g[i])].push_back(get<1>(g[i]));
v[get<1>(g[i])].push_back(get<0>(g[i]));
}
bool visited[n+1]={};
queue <int> q;
q.push(x);
visited[x]=1;
while (!q.empty()){
int f=q.front();
q.pop();
for (auto&i:v[f]){
if (visited[i]) continue;
q.push(i);
visited[i]=1;
}
}
int cnt=0;
for (int i=1; i<=n; i++){
if (visited[i]) cnt++;
}
cout<<cnt<<endl;
}
}
}
# | 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... |