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;
#define fast ios_base::sync_with_stdio();cin.tie();cout.tie();
#define en cout<<endl;
#define ops cout<<"ops"<<endl;
#define line cout<<"---------------------------"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pllll;
typedef string str;
const ll DIM = 1e3 + 7;
const ll DIMM = 1e2 + 7;
const ll DDIM = 7;
const ll INF = 1e18 + 7;
const ll X = 1e5 + 7;
const ll BS = 2e5 + 7;
const ll AS = 26 + 7;
const ll MODULO = 1e9 + 7;
ll nt,n,m,k,q;
ll val,val1;
ll v1,v2,w;
ll d[DIM],vis[DIM];
vector<pllll> a[DIM];
ll type,l,r;
ll res;
void clearvis(){
for(int i=1;i<=n;i++)vis[i]=0;
}
void dfs(ll v,ll w){
res++;
vis[v]=1;
for(auto to:a[v]){
if(vis[to.fi]==1 || d[to.se]<w)continue;
dfs(to.fi,w);
}
}
int main()
{
fast;
//ll x1,y1,x2,y2;
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>v1>>v2>>d[i];
a[v1].push_back({v2,i});
a[v2].push_back({v1,i});
}
cin>>k;
for(int qq=1;qq<=k;qq++){
cin>>type>>l>>r;
if(type==1)d[l]=r;
else{
clearvis();
res=0;
dfs(l,r);
cout<<res<<endl;
}
}
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... |