# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
140456 | 2019-08-03T07:21:29 Z | evpipis | One-Way Streets (CEOI17_oneway) | C++11 | 104 ms | 15996 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] = v.se; 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.se != 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2556 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2808 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 4 ms | 2808 KB | Output is correct |
7 | Correct | 8 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 4 ms | 2808 KB | Output is correct |
10 | Correct | 5 ms | 2808 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2556 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2808 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 4 ms | 2808 KB | Output is correct |
7 | Correct | 8 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 4 ms | 2808 KB | Output is correct |
10 | Correct | 5 ms | 2808 KB | Output is correct |
11 | Correct | 58 ms | 8828 KB | Output is correct |
12 | Correct | 67 ms | 9848 KB | Output is correct |
13 | Correct | 72 ms | 11000 KB | Output is correct |
14 | Correct | 79 ms | 11880 KB | Output is correct |
15 | Correct | 92 ms | 12188 KB | Output is correct |
16 | Correct | 74 ms | 10232 KB | Output is correct |
17 | Correct | 77 ms | 11896 KB | Output is correct |
18 | Correct | 82 ms | 10420 KB | Output is correct |
19 | Correct | 74 ms | 13188 KB | Output is correct |
20 | Correct | 65 ms | 9496 KB | Output is correct |
21 | Correct | 59 ms | 9592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2556 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2808 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 4 ms | 2808 KB | Output is correct |
7 | Correct | 8 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 4 ms | 2808 KB | Output is correct |
10 | Correct | 5 ms | 2808 KB | Output is correct |
11 | Correct | 58 ms | 8828 KB | Output is correct |
12 | Correct | 67 ms | 9848 KB | Output is correct |
13 | Correct | 72 ms | 11000 KB | Output is correct |
14 | Correct | 79 ms | 11880 KB | Output is correct |
15 | Correct | 92 ms | 12188 KB | Output is correct |
16 | Correct | 74 ms | 10232 KB | Output is correct |
17 | Correct | 77 ms | 11896 KB | Output is correct |
18 | Correct | 82 ms | 10420 KB | Output is correct |
19 | Correct | 74 ms | 13188 KB | Output is correct |
20 | Correct | 65 ms | 9496 KB | Output is correct |
21 | Correct | 59 ms | 9592 KB | Output is correct |
22 | Correct | 102 ms | 13060 KB | Output is correct |
23 | Correct | 97 ms | 11484 KB | Output is correct |
24 | Correct | 104 ms | 11512 KB | Output is correct |
25 | Correct | 104 ms | 15996 KB | Output is correct |
26 | Correct | 99 ms | 12664 KB | Output is correct |
27 | Correct | 97 ms | 11696 KB | Output is correct |
28 | Correct | 55 ms | 6648 KB | Output is correct |
29 | Correct | 88 ms | 10360 KB | Output is correct |
30 | Correct | 88 ms | 10616 KB | Output is correct |
31 | Correct | 92 ms | 10772 KB | Output is correct |
32 | Correct | 93 ms | 13048 KB | Output is correct |