# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
572452 | CpDark | Bridges (APIO19_bridges) | C++14 | 3077 ms | 12116 KiB |
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>
#define fastInput ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pii;
typedef vector<pii> vp;
typedef vector<bool> vb;
typedef vector<vb> vvb;
vector<vp> graph;
vll weight;
vb visited;
void dfs(int v, int k) {
visited[v] = true;
for (int i = 0; i < graph[v].size(); i++) {
int u = graph[v][i].first;
ll w = weight[graph[v][i].second];
if (k <= w && !visited[u]) {
dfs(u, k);
}
}
}
int main() {
fastInput;
int n, m;
cin >> n >> m;
graph.resize(n + 1);
weight.resize(m + 1);
int a, b, d;
for (int i = 1; i <= m; i++) {
cin >> a >> b >> d;
graph[a].push_back({ b,i });
graph[b].push_back({ a,i });
weight[i] = d;
}
visited.resize(n + 1,false);
int q;
cin >> q;
int t;
for (int i = 0; i < q; i++) {
cin >> t;
if (t == 1) {
int r;
cin >> b >> r;
weight[b] = r;
}
else {
int s, w;
cin >> s >> w;
dfs(s, w);
int ans = 0;
for (int i = 1; i <= n; i++) {
if (visited[i]) {
ans++;
visited[i] = false;
}
}
cout << ans << endl;
}
}
return 0;
}
Compilation message (stderr)
# | 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... |