Submission #676340

# Submission time Handle Problem Language Result Execution time Memory
676340 2022-12-30T12:08:23 Z stevancv One-Way Streets (CEOI17_oneway) C++14
0 / 100
5 ms 5236 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const ll linf = 1e18;
vector<array<int, 3>> g[N];
int l[N], r[N], dep[N], mn[N], ans[N], tsz;
void Dfs(int s, int e) {
    dep[s] = mn[s] = ++tsz;
    for (auto u : g[s]) {
        if (u[1] == e) continue;
        if (dep[u[0]] == 0) {
            Dfs(u[0], u[1]);
            l[s] |= l[u[0]];
            r[s] |= r[u[0]];
            smin(mn[s], mn[u[0]]);
            if (mn[u[0]] > dep[s]) {
                assert(l[u[0]] + r[u[0]] != 2);
                if (l[u[0]] == 1) ans[u[1]] = u[2] ^ 1;
                else if (r[u[0]] == 1) ans[u[1]] = u[2];
            }
        }
        else smin(mn[s], dep[u[0]]);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back({v, i, 0});
        g[v].push_back({u, i, 1});
    }
    for (int i = 0; i < m; i++) ans[i] = 2;
    int p; cin >> p;
    for (int i = 0; i < p; i++) {
        int u, v;
        cin >> u >> v;
        l[u] = r[v] = 1;
    }
    Dfs(1, -1);
    for (int i = 0; i < m; i++) {
        if (ans[i] == 0) cout << 'R';
        if (ans[i] == 1) cout << 'L';
        if (ans[i] == 2) cout << 'B';
    }
    cout << en;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 5236 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 5236 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 5236 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -