# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
390285 | 2021-04-15T19:00:31 Z | mchang | One-Way Streets (CEOI17_oneway) | C++14 | 4 ms | 6476 KB |
#define pb push_back #define eb emplace_back #define F first #define S second #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; vector<pii> adj[1<<18]; char dir[1<<18]; vector<pii> edges; int pre[1<<18]; int link[1<<18]; int prenum = 1; int N,M,P; int indeg[1<<18]; int outdeg[1<<18]; void dfs(int u, int pi) { pre[u] = link[u] = prenum++; int minlink = pre[u]; for (auto& e : adj[u]) { if (e.S == pi) continue; int v = e.F; if (pre[v] == 0) { dfs(v, e.S); indeg[u]+=indeg[v]; outdeg[u]+=outdeg[v]; } minlink = min(minlink, link[v]); } link[u] = minlink; int deg = outdeg[u]-indeg[u]; if (deg < 0) { // need more coming in from above // pi needs to go from parent->u if (edges[pi].S == u) dir[pi] = 'R'; else dir[pi] = 'L'; } else if (deg > 0) { // there are nodes above me that need me // need to go from u->parent if (edges[pi].F == u) dir[pi] = 'R'; else dir[pi] = 'L'; } } int main() { scanf("%d %d", &N, &M); for (int i = 0; i < M; i++) { int u,v; scanf("%d %d", &u, &v); adj[u].eb(v, i); adj[v].eb(u, i); dir[i] = 'B'; edges.eb(u,v); } scanf("%d", &P); for (int i = 0; i < P; i++) { int u,v; scanf("%d %d", &u, &v); outdeg[u]++; indeg[v]++; } for (int u = 1; u <= N; u++) { if (pre[u] == 0) { dfs(u, -1); } } for (int i = 0; i < M; i++) { printf("%c", dir[i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 6476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 6476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 6476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |