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;
#pragma GCC optimize(2)
#define MAXN 100100
int n,m,q, w[MAXN];
vector<pair<int, int>> adj[MAXN];
bool b[500100];
int ans = 0;
void dfs(int n, int wl) {
if(b[n])
return;
b[n] = 1, ans+=1;
for(auto i: adj[n])
if(w[i.second] >= wl)
dfs(i.first, wl);
}
signed main() {
cin >> n >> m;
for(int i = 0; i < m; i++) {
int a,b;
cin >> a >> b >> w[i];
adj[a].push_back({b,i});
adj[b].push_back({a,i});
}
cin >> q;
for(int i = 0; i < q; i++) {
int t,s,wl;
cin >> t >> s >> wl;
if(t-1) {
ans = 0;
memset(b, 0, sizeof b);
dfs(s, wl);
cout << ans << '\n';
} else {
w[s-1] = wl;
}
}
}
# | 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... |