이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define reu(i,a,b) for (int i=a;i<=b;++i)
#define pb push_back
using namespace std;
int n,m;
const int mx=100002;
int bridge[mx];
vector<pair<int , int> > ke[mx];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
reu(i,1,m){
int u,v,d;
cin>>u>>v;
ke[u].pb({v,i});
ke[v].pb({u,i});
cin>>d;
bridge[i]=d;
}
int q;
cin>>q;
reu(i,1,q)
{
int typ;
cin>>typ;
if (typ==1){
int v,w;
cin>>v>>w;
bridge[v]=w;
}
else {
bool is[mx];
int cnt=1;
memset(is,true,sizeof(is));
int w,s;
cin>>s>>w;
is[s]=false;
queue<int> q;
q.push(s);
while (!q.empty()){
int h=q.front();
q.pop();
for (auto x:ke[h])
if (is[x.first]==true) if (bridge[x.second]>=w){
is[x.first]=false;
q.push(x.first);
++cnt;
}
}
cout<<cnt<<"\n";
}
}
return 0;
}
# | 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... |