이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
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... |