This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int MAX_N = 1e3 + 5, MAX_M = 1e3 + 5, MAX_P = 1e2 + 5;
int n, m;
array<pii, MAX_M> edge;
array<unordered_multiset<int>, MAX_N> adj;
int p;
array<pii, MAX_P> path;
bitset<MAX_N> seen;
void dfs(int u) {
seen[u] = true;
for (int v : adj[u])
if (!seen[v]) dfs(v);
}
array<char, MAX_M> ans;
int main() {
// freopen("way.in", "r", stdin);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int u, v; cin >> u >> v;
edge[i] = {u, v};
adj[u].insert(v), adj[v].insert(u);
}
cin >> p;
for (int i = 1; i <= p; i++) cin >> path[i].first >> path[i].second;
fill(ans.begin(), ans.end(), 'B');
for (int i = 1; i <= m; i++) {
int u = edge[i].first, v = edge[i].second;
adj[v].erase(adj[v].find(u));
for (int j = 1; j <= p; j++) {
int s = path[j].first, f = path[j].second;
seen &= 0, dfs(s);
if (!seen[f]) ans[i] = 'L';
}
adj[v].insert(u);
adj[u].erase(adj[u].find(v));
for (int j = 1; j <= p; j++) {
int s = path[j].first, f = path[j].second;
seen &= 0, dfs(s);
if (!seen[f]) ans[i] = 'R';
}
adj[u].insert(v);
}
for (int i = 1; i <= m; i++) cout << ans[i];
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |