# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434618 | KoD | One-Way Streets (CEOI17_oneway) | C++17 | 324 ms | 28356 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>
template <class T> using Vec = std::vector<T>;
int main() {
int N, M;
std::cin >> N >> M;
Vec<Vec<std::pair<int, int>>> graph(N);
Vec<int> A(M), B(M);
for (int i = 0; i < M; ++i) {
std::cin >> A[i] >> B[i];
A[i] -= 1;
B[i] -= 1;
graph[A[i]].emplace_back(B[i], i);
graph[B[i]].emplace_back(A[i], i);
}
Vec<Vec<int>> children(N);
Vec<int> sum(N), parent(N, -1), depth(N, -1);
auto dfs = [&](auto&& dfs, const int u) -> void {
for (const auto [v, e] : graph[u]) {
if (e != parent[u]) {
if (depth[v] == -1) {
parent[v] = e;
depth[v] = depth[u] + 1;
children[u].push_back(v);
dfs(dfs, v);
sum[u] += sum[v];
} else if (depth[v] < depth[u]) {
sum[u] += 1;
sum[v] -= 1;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |