This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5;
int n, m, q, 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 >> q;
for (int i = 1; i <= q; i++){
int a, b; cin >> a >> b;
actQRY[a]++; actQRY[b]--;
}
for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i, 0);
for (int i = 1; i <= m; i++) cout<<(!ans[i] ? "B" : (ans[i] == -1 ? "L" : "R"));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |