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 DIM 1007
typedef pair<long long, long long> pll;
long long vis[DIM], n, m, u, v, w[DIM], q, t, it, r, s, W, res;
vector<pll> vec[DIM];
void dfs(long long v, long long car)
{
vis[v]=1;
for(auto to : vec[v])
{
if(vis[to.first]==1 || w[to.second]<car) continue;
dfs(to.first, car);
}
return;
}
int main()
{
cin>>n>>m;
for(int i=1; i<=m; i++)
{
cin>>u>>v>>w[i];
vec[u].push_back({v, i});
vec[v].push_back({u, i});
}
cin>>q;
while(q--)
{
cin>>t;
if(t==1)
{
cin>>it>>r;
w[it]=r;
continue;
}
cin>>s>>W;
for(int i=1; i<=n; i++) vis[i]=0;
vis[s]=1;
dfs(s, W);
res=0;
for(int i=1; i<=n; i++) res+=vis[i];
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... |