이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m;
cin>>n>>m;
vector <int> u(m+1),v(m+1),w(m+1);
for(int i=1;i<=m;i++){
cin>>u[i]>>v[i]>>w[i];
}
int qu;cin>>qu;
while(qu--){
int type,ver,x;
cin>>type>>ver>>x;
if(type==1)w[ver]=x;
else{
vector <pair <int,int> > g[n+1];
for(int i=1;i<=m;i++){
g[u[i]].pb({v[i],w[i]});
g[v[i]].pb({u[i],w[i]});
}
vector <int> vis(n+1);
vis[ver]=1;
int cnt=1;
queue <int> q;q.push(ver);
while(!q.empty()){
int v=q.front();
q.pop();
for(auto to : g[v]){
if(!vis[to.ff] && to.ss>=x){
vis[to.ff]=1;
cnt++;
q.push(to.ff);
}
}
}
cout<<cnt<<"\n";
}
}
}
/*
3 4
1 2 5
2 3 2
3 1 4
2 3 8
5
2 1 5
1 4 1
2 2 5
1 1 1
2 3 2
*/
# | 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... |