This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long INF = 1e18 + 7;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;
int n, m, q;
vector <pair<int, int>> a[N];
array<int, 3> edge[N];
bool f[N];
void dfs(int u, int val){
f[u] = true;
for(pair<int, int> st : a[u]){
int i = st.first, w = st.second;
if (f[i] || w < val) continue;
dfs(i, val);
}
}
void solve()
{
cin >> n >> m;
for(int i = 1; i <= m; ++i){
int u, v, w; cin >> u >> v >> w;
a[u].push_back({v, w});
a[v].push_back({u, w});
edge[i] = {u, v, w};
}
cin >> q;
while (q--){
int type, u, val; cin >> type >> u >> val;
if (type == 1){
edge[u][2] = val;
for(int i = 1; i <= n; ++i) a[i].clear();
for(int i = 1; i <= m; ++i){
int u = edge[i][0], v = edge[i][1], w = edge[i][2];
a[u].push_back({v, w});
a[v].push_back({u, w});
}
} else{
fill(f + 1, f + n + 1, 0);
dfs(u, val);
int cnt = 0;
for(int i = 1; i <= n; ++i) cnt += f[i];
cout << cnt << endl;
}
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("codeforces.inp","r",stdin);
// freopen("codeforces.out","w",stdout);
int t = 1; // cin >> t;
while (t--)
{
solve();
}
}
# | 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... |