# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
77022 | 2018-09-20T05:37:58 Z | win11905 | One-Way Streets (CEOI17_oneway) | C++11 | 138 ms | 47064 KB |
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 1e5+5; int n, m, p, d1[N], d2[N]; char Answer[N]; bitset<N> check, checkE; pii E[N]; vector<pii> g[N]; void dfs(int u, int p) { check[u] = true; for(pii v : g[u]) if(v.x != p) { if(check[v.x]) { if(E[v.y].x == u) swap(E[v.y].x, E[v.y].y); } else checkE[v.y] = true, dfs(v.x, u); } } void solve(int u, int p) { check[u] = false; for(pii v : g[u]) if(v.x != p) if(check[v.x]) { solve(v.x, u); Answer[v.y] = 'B'; d1[u] += d1[v.x], d2[u] += d2[v.x]; if(d1[v.x] || !d2[v.x]) continue; Answer[v.y] = (d2[v.x] > 0 ? v.x : u) == E[v.y].x ? 'R' : 'L'; } } int main() { scanf("%d %d", &n, &m); for(int i = 0, u, v; i < m; ++i) { scanf("%d %d", &u, &v); g[u].emplace_back(v, i), g[v].emplace_back(u, i); E[i] = pii(u, v); } for(int i = 1; i <= n; ++i) if(!check[i]) dfs(i, 0); for(int i = 0; i < m; ++i) if(!checkE[i]) Answer[i] = 'B', d1[E[i].x]++, d1[E[i].y]--; scanf("%d", &p); for(int i = 0, a, b; i < p; ++i) { scanf("%d %d", &a, &b); d2[a]++, d2[b]--; } for(int i = 1; i <= n; ++i) if(check[i]) solve(i, 0); printf("%s", Answer); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 5 ms | 2872 KB | Output is correct |
4 | Correct | 5 ms | 2872 KB | Output is correct |
5 | Correct | 5 ms | 3116 KB | Output is correct |
6 | Correct | 5 ms | 3116 KB | Output is correct |
7 | Correct | 4 ms | 3316 KB | Output is correct |
8 | Correct | 4 ms | 3316 KB | Output is correct |
9 | Correct | 5 ms | 3316 KB | Output is correct |
10 | Correct | 5 ms | 3316 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 5 ms | 2872 KB | Output is correct |
4 | Correct | 5 ms | 2872 KB | Output is correct |
5 | Correct | 5 ms | 3116 KB | Output is correct |
6 | Correct | 5 ms | 3116 KB | Output is correct |
7 | Correct | 4 ms | 3316 KB | Output is correct |
8 | Correct | 4 ms | 3316 KB | Output is correct |
9 | Correct | 5 ms | 3316 KB | Output is correct |
10 | Correct | 5 ms | 3316 KB | Output is correct |
11 | Correct | 57 ms | 9320 KB | Output is correct |
12 | Correct | 73 ms | 11272 KB | Output is correct |
13 | Correct | 78 ms | 13272 KB | Output is correct |
14 | Correct | 93 ms | 15040 KB | Output is correct |
15 | Correct | 107 ms | 16152 KB | Output is correct |
16 | Correct | 98 ms | 16152 KB | Output is correct |
17 | Correct | 76 ms | 18296 KB | Output is correct |
18 | Correct | 76 ms | 18296 KB | Output is correct |
19 | Correct | 79 ms | 21592 KB | Output is correct |
20 | Correct | 66 ms | 21592 KB | Output is correct |
21 | Correct | 75 ms | 21592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 5 ms | 2872 KB | Output is correct |
4 | Correct | 5 ms | 2872 KB | Output is correct |
5 | Correct | 5 ms | 3116 KB | Output is correct |
6 | Correct | 5 ms | 3116 KB | Output is correct |
7 | Correct | 4 ms | 3316 KB | Output is correct |
8 | Correct | 4 ms | 3316 KB | Output is correct |
9 | Correct | 5 ms | 3316 KB | Output is correct |
10 | Correct | 5 ms | 3316 KB | Output is correct |
11 | Correct | 57 ms | 9320 KB | Output is correct |
12 | Correct | 73 ms | 11272 KB | Output is correct |
13 | Correct | 78 ms | 13272 KB | Output is correct |
14 | Correct | 93 ms | 15040 KB | Output is correct |
15 | Correct | 107 ms | 16152 KB | Output is correct |
16 | Correct | 98 ms | 16152 KB | Output is correct |
17 | Correct | 76 ms | 18296 KB | Output is correct |
18 | Correct | 76 ms | 18296 KB | Output is correct |
19 | Correct | 79 ms | 21592 KB | Output is correct |
20 | Correct | 66 ms | 21592 KB | Output is correct |
21 | Correct | 75 ms | 21592 KB | Output is correct |
22 | Correct | 118 ms | 25124 KB | Output is correct |
23 | Correct | 133 ms | 25752 KB | Output is correct |
24 | Correct | 138 ms | 28084 KB | Output is correct |
25 | Correct | 119 ms | 34884 KB | Output is correct |
26 | Correct | 116 ms | 34884 KB | Output is correct |
27 | Correct | 108 ms | 35156 KB | Output is correct |
28 | Correct | 74 ms | 35156 KB | Output is correct |
29 | Correct | 98 ms | 37968 KB | Output is correct |
30 | Correct | 101 ms | 40356 KB | Output is correct |
31 | Correct | 114 ms | 42884 KB | Output is correct |
32 | Correct | 102 ms | 47064 KB | Output is correct |