#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;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
3820 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |