# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140455 | 2019-08-03T07:10:19 Z | evpipis | One-Way Streets (CEOI17_oneway) | C++11 | 5 ms | 2808 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back typedef pair<int, int> ii; const int len = 1e5+5; int out[len], num[len], low[len], par[len], sum[len], cnt; ii edge[len]; vector<ii> adj[len]; void dfs(int u){ num[u] = low[u] = ++cnt; for (int j = 0; j < adj[u].size(); j++){ ii v = adj[u][j]; if (!num[v.fi]){ par[v.fi] = u; dfs(v.fi); if (low[v.fi] > num[u]){ if (sum[v.fi] > 0) out[v.se] = edge[v.se].fi==v.fi?1:-1; if (sum[v.fi] < 0) out[v.se] = edge[v.se].fi==u?1:-1; } low[u] = min(low[u], low[v.fi]); sum[u] += sum[v.fi]; } else if (v.fi != par[u]){ low[u] = min(low[u], num[v.fi]); } } } int main(){ int n, m, q; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++){ int a, b; scanf("%d %d", &a, &b); edge[i] = mp(a, b); adj[a].pb(mp(b, i)); adj[b].pb(mp(a, i)); } scanf("%d", &q); while (q--){ int a, b; scanf("%d %d", &a, &b); sum[a]++; sum[b]--; } for (int i = 1; i <= n; i++) if (!num[i]) dfs(i); for (int i = 0; i < m; i++){ if (out[i] > 0) printf("R"); else if (out[i] == 0) printf("B"); else printf("L"); } printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 4 ms | 2808 KB | Output is correct |
4 | Correct | 5 ms | 2808 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 4 ms | 2680 KB | Output is correct |
7 | Correct | 5 ms | 2808 KB | Output is correct |
8 | Correct | 4 ms | 2808 KB | Output is correct |
9 | Incorrect | 5 ms | 2680 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 4 ms | 2808 KB | Output is correct |
4 | Correct | 5 ms | 2808 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 4 ms | 2680 KB | Output is correct |
7 | Correct | 5 ms | 2808 KB | Output is correct |
8 | Correct | 4 ms | 2808 KB | Output is correct |
9 | Incorrect | 5 ms | 2680 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 4 ms | 2808 KB | Output is correct |
4 | Correct | 5 ms | 2808 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 4 ms | 2680 KB | Output is correct |
7 | Correct | 5 ms | 2808 KB | Output is correct |
8 | Correct | 4 ms | 2808 KB | Output is correct |
9 | Incorrect | 5 ms | 2680 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |