Submission #823711

# Submission time Handle Problem Language Result Execution time Memory
823711 2023-08-13T02:29:55 Z 12345678 One-Way Streets (CEOI17_oneway) C++17
100 / 100
51 ms 13052 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e5+5;
int n, m, p, ds[nx], l[nx], dp[nx], u, v, t;
char ans[2*nx];
vector<vector<tuple<int, int, bool>>> d(nx);

void tarj(int u, int pidx)
{
    ds[u]=l[u]=++t;
    for (auto [idx, v, dr]:d[u])
    {
        if (idx==pidx) continue;
        if (!ds[v])
        {
            tarj(v, idx);
            if (ds[u]>=l[v]||dp[v]==0) ans[idx]='B';
            else 
            {
                if (dp[v]>0) ans[idx]=(dr==1)?'L':'R';
                else ans[idx]=(dr==1)?'R':'L';
            }
            dp[u]+=dp[v];
            l[u]=min(l[v], l[u]);
        }
        else l[u]=min(l[u], ds[v]), ans[idx]='B';
        //printf("%d %d %d %c\n", u, v, idx, ans[idx]);
    }
    //printf("%d %d %d\n", u, ds[u], l[u]);
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m;
    for (int i=0; i<m; i++) cin>>u>>v, d[u].push_back({i, v, 1}), d[v].push_back({i, u, 0});
    cin>>p;
    for (int i=0; i<p; i++) cin>>u>>v, dp[u]++, dp[v]--;
    for (int i=1; i<=n; i++) if (!ds[i]) tarj(i, -1);
    for (int i=0; i<m; i++) cout<<ans[i];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2772 KB Output is correct
4 Correct 2 ms 2692 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2692 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2772 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2772 KB Output is correct
4 Correct 2 ms 2692 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2692 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2772 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 27 ms 8652 KB Output is correct
12 Correct 29 ms 9516 KB Output is correct
13 Correct 35 ms 10332 KB Output is correct
14 Correct 34 ms 10772 KB Output is correct
15 Correct 33 ms 10716 KB Output is correct
16 Correct 30 ms 8752 KB Output is correct
17 Correct 28 ms 10188 KB Output is correct
18 Correct 30 ms 8700 KB Output is correct
19 Correct 30 ms 11260 KB Output is correct
20 Correct 28 ms 8792 KB Output is correct
21 Correct 27 ms 8524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2772 KB Output is correct
4 Correct 2 ms 2692 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2692 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2772 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 27 ms 8652 KB Output is correct
12 Correct 29 ms 9516 KB Output is correct
13 Correct 35 ms 10332 KB Output is correct
14 Correct 34 ms 10772 KB Output is correct
15 Correct 33 ms 10716 KB Output is correct
16 Correct 30 ms 8752 KB Output is correct
17 Correct 28 ms 10188 KB Output is correct
18 Correct 30 ms 8700 KB Output is correct
19 Correct 30 ms 11260 KB Output is correct
20 Correct 28 ms 8792 KB Output is correct
21 Correct 27 ms 8524 KB Output is correct
22 Correct 48 ms 10216 KB Output is correct
23 Correct 43 ms 8648 KB Output is correct
24 Correct 51 ms 8672 KB Output is correct
25 Correct 46 ms 13052 KB Output is correct
26 Correct 48 ms 9772 KB Output is correct
27 Correct 41 ms 8644 KB Output is correct
28 Correct 23 ms 6548 KB Output is correct
29 Correct 41 ms 8396 KB Output is correct
30 Correct 40 ms 8620 KB Output is correct
31 Correct 41 ms 8904 KB Output is correct
32 Correct 40 ms 10572 KB Output is correct