답안 #771526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771526 2023-07-03T05:53:29 Z PoonYaPat One-Way Streets (CEOI17_oneway) C++14
100 / 100
45 ms 12748 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n,m,mark1[100001],mark2[100001],dis[100001],k[100001];
vector<pii> adj[100001];
pii edge[100001];
bool vis[100001],use[100001];
string ans;

void dfs(int x) {
    vis[x]=true;
    for (auto s : adj[x]) {
        if (use[s.second]) continue;
        use[s.second]=true;
        if (vis[s.first]) {
            ++mark2[x];
            --mark2[s.first];
            ans[s.second]='B';
        } else {
            dfs(s.first);

            if (mark2[s.first]) ans[s.second]='B';
            else {
                if (mark1[s.first]>0) {
                    if (edge[s.second].first==x) ans[s.second]='L';
                    else ans[s.second]='R';
                } else if (mark1[s.first]<0) {
                    if (edge[s.second].first==x) ans[s.second]='R';
                    else ans[s.second]='L';
                } else ans[s.second]='B';
            }

            mark2[x]+=mark2[s.first];
            mark1[x]+=mark1[s.first];
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for (int i=0; i<m; ++i) {
        int a,b; cin>>a>>b;
        ans+=" ";
        adj[a].push_back(pii(b,i));
        adj[b].push_back(pii(a,i));
        edge[i]=pii(a,b);
    }
    int k; cin>>k;
    while (k--) {
        int a,b; cin>>a>>b;
        mark1[a]++;
        mark1[b]--;
    }

    for (int i=1; i<=n; ++i) if (!vis[i]) dfs(i);
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2772 KB Output is correct
6 Correct 2 ms 2676 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 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 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2772 KB Output is correct
6 Correct 2 ms 2676 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 23 ms 7800 KB Output is correct
12 Correct 28 ms 8668 KB Output is correct
13 Correct 28 ms 9628 KB Output is correct
14 Correct 32 ms 10136 KB Output is correct
15 Correct 34 ms 10172 KB Output is correct
16 Correct 28 ms 8320 KB Output is correct
17 Correct 25 ms 9796 KB Output is correct
18 Correct 29 ms 8276 KB Output is correct
19 Correct 27 ms 10944 KB Output is correct
20 Correct 25 ms 8156 KB Output is correct
21 Correct 30 ms 7856 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 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2772 KB Output is correct
6 Correct 2 ms 2676 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 23 ms 7800 KB Output is correct
12 Correct 28 ms 8668 KB Output is correct
13 Correct 28 ms 9628 KB Output is correct
14 Correct 32 ms 10136 KB Output is correct
15 Correct 34 ms 10172 KB Output is correct
16 Correct 28 ms 8320 KB Output is correct
17 Correct 25 ms 9796 KB Output is correct
18 Correct 29 ms 8276 KB Output is correct
19 Correct 27 ms 10944 KB Output is correct
20 Correct 25 ms 8156 KB Output is correct
21 Correct 30 ms 7856 KB Output is correct
22 Correct 37 ms 9812 KB Output is correct
23 Correct 45 ms 8196 KB Output is correct
24 Correct 39 ms 8336 KB Output is correct
25 Correct 40 ms 12748 KB Output is correct
26 Correct 38 ms 9396 KB Output is correct
27 Correct 38 ms 8300 KB Output is correct
28 Correct 21 ms 5852 KB Output is correct
29 Correct 35 ms 7780 KB Output is correct
30 Correct 43 ms 7888 KB Output is correct
31 Correct 36 ms 8284 KB Output is correct
32 Correct 35 ms 10064 KB Output is correct