#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
vector<int> adj[MAXN+1];
map<pair<int,int>, int> edge;
map<pair<int,int>, char> ans;
int dep[MAXN+1], low[MAXN+1], cntX[MAXN+1], cntY[MAXN+1];
void dfs(int v, int p) {
dep[v] = low[v] = dep[p] + 1;
for (int u : adj[v]) {
if (u == p) continue;
if (dep[u] == 0) {
dfs(u, v);
low[v] = min(low[v], low[u]);
cntX[v] += cntX[u];
cntY[v] += cntY[u];
} else {
low[v] = min(low[v], dep[u]);
}
}
if (v == 1) return;
int lowernode = v;
if (edge.find({v, p}) == edge.end()) swap(p, v);
if (dep[v] == low[v] && edge[{v, p}] == 1) { // p-v is a bridge
if (cntX[lowernode] == cntY[lowernode]) return; // no path crosses this bridge
if (cntX[lowernode] > cntY[lowernode]) {
ans[{v, p}] = 'R';
} else {
ans[{v, p}] = 'L';
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n,m; cin >> n >> m;
pair<int,int> aaa[m];
for (int i = 0; i < m; i++) {
int a,b; cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
edge[{a,b}]++;
aaa[i] = {a, b};
}
int p; cin >> p;
while (p--) {
int x,y; cin >> x >> y;
cntX[x]++, cntY[y]++;
}
dfs(1, 0);
for (auto [a,b] : aaa) {
cout << (ans[{a,b}] == 0 ? 'B' : ans[{a,b}]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |