| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1357884 | mxhrvs | Currents (EGOI25_currents) | C++20 | 156 ms | 27256 KiB |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<vector<int>> v(n);
vector<vector<int>> v1(n);
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
v[x].push_back(y);
v1[y].push_back(x);
}
vector<int> dis(n, inf);
queue<int> q;
dis[0] = 0;
q.push(0);
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : v[u]) {
if (dis[v] == inf) {
dis[v] = dis[u] + 1;
q.push(v);
}
}
}
vector<int> result(n, inf);
result[n - 1] = 0;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
pq.push({0, n - 1});
while (!pq.empty()) {
int d = pq.top().first;
int u = pq.top().second;
pq.pop();
if (d > result[u]) continue;
for (int i : v1[u]) {
int k = max(dis[i], 1 + result[u]);
if (result[i] > k) {
result[i] = k;
pq.push({result[i], i});
}
}
}
for (int i = 0; i < n - 1; i++) {
if (result[i] == inf) cout << -1;
else cout << result[i];
if (i < n - 2) cout << " ";
}
cout << endl;
} | # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
