답안 #823713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823713 2023-08-13T02:32:56 Z 12345678 One-Way Streets (CEOI17_oneway) C++17
100 / 100
54 ms 12552 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], l[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];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2772 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 1 ms 2644 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 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2772 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 1 ms 2644 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 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 26 ms 8232 KB Output is correct
12 Correct 28 ms 9060 KB Output is correct
13 Correct 31 ms 9812 KB Output is correct
14 Correct 34 ms 10156 KB Output is correct
15 Correct 32 ms 10260 KB Output is correct
16 Correct 29 ms 8300 KB Output is correct
17 Correct 28 ms 9708 KB Output is correct
18 Correct 30 ms 8276 KB Output is correct
19 Correct 39 ms 10776 KB Output is correct
20 Correct 27 ms 8256 KB Output is correct
21 Correct 25 ms 8096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2772 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 1 ms 2644 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 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 26 ms 8232 KB Output is correct
12 Correct 28 ms 9060 KB Output is correct
13 Correct 31 ms 9812 KB Output is correct
14 Correct 34 ms 10156 KB Output is correct
15 Correct 32 ms 10260 KB Output is correct
16 Correct 29 ms 8300 KB Output is correct
17 Correct 28 ms 9708 KB Output is correct
18 Correct 30 ms 8276 KB Output is correct
19 Correct 39 ms 10776 KB Output is correct
20 Correct 27 ms 8256 KB Output is correct
21 Correct 25 ms 8096 KB Output is correct
22 Correct 39 ms 9692 KB Output is correct
23 Correct 39 ms 8100 KB Output is correct
24 Correct 41 ms 8268 KB Output is correct
25 Correct 54 ms 12552 KB Output is correct
26 Correct 42 ms 9240 KB Output is correct
27 Correct 39 ms 8236 KB Output is correct
28 Correct 22 ms 5968 KB Output is correct
29 Correct 39 ms 7880 KB Output is correct
30 Correct 50 ms 8088 KB Output is correct
31 Correct 40 ms 8320 KB Output is correct
32 Correct 39 ms 10020 KB Output is correct