#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()
template<class S, class T>
bool chmin(S &a, const T &b) {
return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
return a < b ? (a = b) == b : false;
}
const int N = 1e5 + 1;
vector<vector<int>> g(N);
bool vis[N];
int parent[N];
map<pair<int, int>, bool> used;
void dfs(int v, int p) {
vis[v] = true;
parent[v] = p;
for (int to : g[v]) {
if (!vis[to] && (used[{v, to}] || !used[{to, v}])) {
dfs(to, v);
}
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m; cin >> n >> m;
int a[m], b[m];
for (int i = 0; i < m; ++i) {
cin >> a[i] >> b[i];
g[a[i]].push_back(b[i]);
g[b[i]].push_back(a[i]);
}
int p; cin >> p;
int u[p], v[p];
for (int i = 0; i < p; ++i) {
cin >> u[i] >> v[i];
dfs(u[i], -1);
vector<int> path;
int x = v[i];
while (x != -1) {
path.push_back(x);
x = parent[x];
}
reverse(all(path));
for (int i = 1; i < size(path); ++i) {
used[{path[i - 1], path[i]}] = true;
}
memset(vis, false, sizeof(vis));
memset(parent, 0, sizeof(parent));
}
for (int i = 0; i < m; ++i) {
if (used[{a[i], b[i]}]) {
cout << 'R';
} else if (used[{b[i], a[i]}]) {
cout << 'L';
} else {
cout << 'B';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |