Submission #488446

#TimeUsernameProblemLanguageResultExecution timeMemory
488446SirCovidThe19thOne-Way Streets (CEOI17_oneway)C++17
0 / 100
1 ms2680 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...