이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
const int N = 5e4 + 10;
set<pair<pii, int>> gr[N];
bool us[N];
vector<int> now;
void dfs (int city, int w) {
us[city] = 1;
now.push_back(city);
for (auto i : gr[city]) {
if (us[i.fi.fi] || i.fi.se < w)
continue;
dfs(i.fi.fi, w);
}
}
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
int n, m, q;
cin >> n >> m;
int u[m + 1], v[m + 1], w[m + 1];
for (int i = 1; i <= m; ++i) {
cin >> u[i] >> v[i] >> w[i];
gr[u[i]].insert({{v[i], w[i]}, i});
gr[v[i]].insert({{u[i], w[i]}, i});
}
cin >> q;
while (q--) {
int type;
int l, r;
cin >> type >> l >> r;
if (type == 1) {
gr[u[l]].erase({{v[l], w[l]}, l});
gr[v[l]].erase({{u[l], w[l]}, l});
w[l] = r;
gr[u[l]].insert({{v[l], w[l]}, l});
gr[v[l]].insert({{u[l], w[l]}, l});
} else {
now.clear();
dfs(l, r);
for (int i : now)
us[i] = 0;
cout << now.size() << '\n';
}
}
}
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... |