이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,m;
cin>>n>>m;
multiset<pair<ll,ll>>adj[n];
vector<array<ll,3>>edge;
for(ll i=0;i<m;i++){
ll u,v,d;
cin>>u>>v>>d;
u--,v--;
adj[u].insert({v,d});
adj[v].insert({u,d});
edge.pb({u,v,d});
}
vector<bool>used(n);
ll q;
cin>>q;
while(q--){
ll t;
cin>>t;
if(t==1){
ll b,r;
cin>>b>>r;
b--;
auto [u,v,d]=edge[b];
adj[u].erase(adj[u].find({v,d}));
adj[v].erase(adj[v].find({u,d}));
edge[b][2]=r;
d=r;
adj[u].insert({v,d});
adj[v].insert({u,d});
}
else{
ll s,w;
cin>>s>>w;
s--;
fill(all(used),0);
function <void(ll)> dfs=[&](ll x){
used[x]=true;
for(auto [y,d]:adj[x]){
if(d>=w&&!used[y]){
dfs(y);
}
}
};
dfs(s);
ll ans=0;
for(ll i=0;i<n;i++){
if(used[i]==true){
ans++;
}
}
cout<<ans<<"\n";
}
}
}
# | 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... |