#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const ll linf = 1e18;
vector<array<int, 3>> g[N];
int a[N], dep[N], mn[N], ans[N];
void Dfs(int s, int e, int d) {
dep[s] = mn[s] = d;
for (auto u : g[s]) {
if (u[1] == e) continue;
if (dep[u[0]] == 0) {
Dfs(u[0], u[1], d + 1);
if (mn[u[0]] > dep[s]) {
if (a[u[0]] > 0) ans[u[1]] = u[2] ^ 1;
else if (a[u[0]] < 0) ans[u[1]] = u[2];
}
a[s] += a[u[0]];
smin(mn[s], mn[u[0]]);
}
else smin(mn[s], dep[u[0]]);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
g[u].push_back({v, i, 0});
g[v].push_back({u, i, 1});
}
for (int i = 0; i < m; i++) ans[i] = 2;
int p; cin >> p;
for (int i = 0; i < p; i++) {
int u, v;
cin >> u >> v;
a[u] += 1;
a[v] -= 1;
}
for (int i = 1; i <= n; i++) {
if (dep[i] == 0) Dfs(i, -1, 1);
}
for (int i = 0; i < m; i++) {
if (ans[i] == 0) cout << 'R';
if (ans[i] == 1) cout << 'L';
if (ans[i] == 2) cout << 'B';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2772 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2680 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2688 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2772 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2680 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2688 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
44 ms |
9548 KB |
Output is correct |
12 |
Correct |
37 ms |
10436 KB |
Output is correct |
13 |
Correct |
45 ms |
11216 KB |
Output is correct |
14 |
Correct |
60 ms |
11584 KB |
Output is correct |
15 |
Correct |
53 ms |
11656 KB |
Output is correct |
16 |
Correct |
49 ms |
9724 KB |
Output is correct |
17 |
Correct |
48 ms |
11128 KB |
Output is correct |
18 |
Correct |
47 ms |
9676 KB |
Output is correct |
19 |
Correct |
42 ms |
12224 KB |
Output is correct |
20 |
Correct |
37 ms |
9768 KB |
Output is correct |
21 |
Correct |
39 ms |
9420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2772 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2680 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2688 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
44 ms |
9548 KB |
Output is correct |
12 |
Correct |
37 ms |
10436 KB |
Output is correct |
13 |
Correct |
45 ms |
11216 KB |
Output is correct |
14 |
Correct |
60 ms |
11584 KB |
Output is correct |
15 |
Correct |
53 ms |
11656 KB |
Output is correct |
16 |
Correct |
49 ms |
9724 KB |
Output is correct |
17 |
Correct |
48 ms |
11128 KB |
Output is correct |
18 |
Correct |
47 ms |
9676 KB |
Output is correct |
19 |
Correct |
42 ms |
12224 KB |
Output is correct |
20 |
Correct |
37 ms |
9768 KB |
Output is correct |
21 |
Correct |
39 ms |
9420 KB |
Output is correct |
22 |
Correct |
62 ms |
12236 KB |
Output is correct |
23 |
Correct |
81 ms |
10696 KB |
Output is correct |
24 |
Correct |
79 ms |
10872 KB |
Output is correct |
25 |
Correct |
57 ms |
15312 KB |
Output is correct |
26 |
Correct |
56 ms |
11852 KB |
Output is correct |
27 |
Correct |
57 ms |
10740 KB |
Output is correct |
28 |
Correct |
28 ms |
7424 KB |
Output is correct |
29 |
Correct |
54 ms |
10416 KB |
Output is correct |
30 |
Correct |
57 ms |
10524 KB |
Output is correct |
31 |
Correct |
56 ms |
10872 KB |
Output is correct |
32 |
Correct |
48 ms |
12648 KB |
Output is correct |