#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5;
int n, m, p, edgIn[mx], active[mx], actQRY[mx], ans[mx]; bool vis[mx]; vector<pair<int, int>> adj[mx];
void dfs(int cur, int p){
vis[cur] = 1;
for (auto [nxt, id] : adj[cur]) if (nxt != p){
if (!vis[nxt]){
dfs(nxt, cur);
active[cur] += active[nxt];
if (!active[nxt]) ans[id] = actQRY[nxt]; //current edg is bridge
actQRY[cur] += actQRY[nxt];
}
else edgIn[nxt]++, active[cur]++;
}
active[cur] -= edgIn[cur];
}
int main(){
cin >> n >> m;
for (int i = 1; i <= m; i++){
int a, b; cin >> a >> b;
adj[a].push_back({b, i}); adj[b].push_back({a, i});
}
cin >> p;
for (int i = 1; i <= p; i++){
int a, b; cin >> a >> b;
actQRY[a]++; actQRY[b]--;
}
dfs(1, 0);
for (int i = 1; i <= m; i++) cout<<(!ans[i] ? "B" : (ans[i] == -1 ? "L" : "R"));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |