#include <bits/stdc++.h>
using namespace std;
#define task "test"
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define bit(s, i) (((s) >> (i)) & 1)
#define ii pair <int, int>
#define vii vector <ii>
#define vi vector <int>
#define fi first
#define se second
#define ll long long
#define eb emplace_back
#define pb push_back
#define __builtin_popcount __builtin_popcountll
void solve();
int32_t main() {
if(fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
int tc = 1; // cin >> tc;
FOR(i, 1, tc) {
solve();
}
}
const int N = 1e5+5;
int n, m, p, tot_st[N], tot_en[N], num[N], low[N], ans[N], Time;
vector <pair <int, ii>> g[N], nwg[N];
void pre_dfs(int u, int id) {
num[u] = low[u] = ++Time;
for(pair <int, ii> i:g[u]) if(i.se.fi != id) {
int v = i.fi;
if(!num[v]) {
nwg[u].eb(i);
pre_dfs(v, i.se.fi);
low[u] = min(low[u], low[v]);
tot_st[u] += tot_st[v];
tot_en[u] += tot_en[v];
}
else {
low[u] = min(low[u], num[v]);
}
}
}
void dfs(int u, int st, int en) {
int tmp_st = st + tot_st[u], tmp_en = en + tot_en[u];
// for(pair <int, ii> i:nwg[u]) {
// int v = i.fi;
// tmp_st += tot_st[v];
// tmp_st += tot_en[v];
// }
for(pair <int, ii> i:nwg[u]) {
int v = i.fi, id = i.se.fi, res = i.se.se;
int out_st = tmp_st - tot_st[v],
out_en = tmp_en - tot_en[v];
if(low[v] == num[v]) {
// cout << u << " " << v << " " << res << '\n';
if(out_st > 0 && tot_en[v] > 0) ans[id] = res;
else if(out_en > 0 && tot_st[v] > 0) ans[id] = res^1;
}
dfs(v, out_st, out_en);
}
}
void solve() {
cin >> n >> m;
FOR(i, 1, m) {
int x, y; cin >> x >> y;
g[x].pb({y, {i, 0}}); g[y].pb({x, {i, 1}});
}
cin >> p;
FOR(i, 1, p) {
int x, y; cin >> x >> y;
tot_st[x]++; tot_en[y]++;
}
memset(ans, -1, sizeof(ans));
pre_dfs(1, 0);
dfs(1, 0, 0);
FOR(i, 1, m) {
if(ans[i] == -1) cout << 'B';
if(ans[i] == 0) cout << 'R';
if(ans[i] == 1) cout << 'L';
}
}
Compilation message
oneway.cpp: In function 'int32_t main()':
oneway.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
oneway.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |