# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
207362 | dolphingarlic | Pipes (BOI13_pipes) | C++14 | 558 ms | 58872 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 FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int n, m;
set<pair<int, int>> graph[100001];
int c[100001], ans[500001], visited[100001], alt_sum = 0;
void dfs1(int node, int parity = 1) {
visited[node] = parity;
for (pair<int, int> i : graph[node]) if (!visited[i.first]) {
dfs1(i.first, 3 - parity);
if (parity == 1) alt_sum += c[i.first];
else alt_sum -= c[i.first];
}
}
void compress() {
queue<int> leaves;
FOR(i, 1, n + 1) if (graph[i].size() == 1) leaves.push(i);
while (leaves.size()) {
int curr = leaves.front();
leaves.pop();
for (pair<int, int> i : graph[curr]) {
graph[i.first].erase({curr, i.second});
ans[i.second] = 2 * c[curr];
c[i.first] -= c[curr];
if (graph[i.first].size() == 1) leaves.push(i.first);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |