Submission #469254

#TimeUsernameProblemLanguageResultExecution timeMemory
469254islingrOne-Way Streets (CEOI17_oneway)C++17
100 / 100
77 ms15424 KiB
#include <bits/stdc++.h> using namespace std; template<class T> bool uin(T& a, const T& b) { return a > b ? a = b, true : false; } signed main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; vector<vector<int>> g(n); vector<int> l(m), r(m), in(n), low(n), s(n); for (int e = 0; e < m; ++e) { cin >> l[e] >> r[e]; --l[e]; --r[e]; g[l[e]].push_back(e); g[r[e]].push_back(e); } int q; cin >> q; while (q--) { int u, v; cin >> u >> v; --u; --v; ++s[u]; --s[v]; } string ans(m, 'B'); int timer = 0; constexpr char dir[2] = {'L', 'R'}; auto dfs = [&](const auto &self, int u, int p) -> void { low[u] = in[u] = ++timer; for (auto e : g[u]) { if (e == p) continue; int v = l[e] ^ r[e] ^ u; if (in[v] != 0) uin(low[u], in[v]); else { self(self, v, e); uin(low[u], low[v]); if (s[v] != 0 && in[u] < low[v]) ans[e] = dir[(l[e] != v) ^ (s[v] > 0)]; s[u] += s[v]; } } }; for (int u = 0; u < n; ++u) if (in[u] == 0) dfs(dfs, u, -1); cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...