답안 #116083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116083 2019-06-10T12:35:32 Z Meloric One-Way Streets (CEOI17_oneway) C++14
100 / 100
233 ms 15860 KB
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>

using namespace std;
vector<vector<int>> g;
struct edge{
    int u, v;
    char dir;
};
vector<edge> ed;
vector<int> tin, low, val, vis;
int n, m, counter;

void dfs(int v, int p){
    tin[v] = low[v] = counter;
    counter++;
    vis[v] = 1;
    for(auto ch : g[v]){
        if(ch == p)continue;
        int nx = (v==ed[ch].u) ? ed[ch].v : ed[ch].u;
        if(vis[nx]){
            low[v] = min(low[v], tin[nx]);
            continue;
        }
        dfs(nx, ch);
        low[v] = min(low[v], low[nx]);
        pii cor;
        if(tin[v] < low[nx]){
            if(val[nx] == 0)continue;
            if(val[nx] < 0){
                cor = {v, nx};
            }else{
                cor = {nx, v};
            }
            if(ed[ch].u == cor.X)ed[ch].dir = 'R';
            else ed[ch].dir = 'L';
        }
        val[v]+=val[nx];
    }
}
int main(){
    cin >> n >> m;
    counter = 0;
    g.assign(n, vector<int>());
    tin.assign(n, 0);
    low.assign(n, 0);
    val.assign(n, 0);
    vis.assign(n, 0);
    for(int i = 0; i< m; i++){
        int c, d; cin >> c >> d; c--; d--;
        ed.pb({c, d, 'B'});
        g[c].pb(i); g[d].pb(i);
    }
    int q; cin >> q;
    while(q--){
        int c, d; cin >> c >> d; c--; d--;
        val[c]++; val[d]--;
    }
    for(int i = 0;i<n; i++){
        if(!vis[i])dfs(i, -1);
    }
    for(auto i : ed){
        cout << i.dir;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 87 ms 6196 KB Output is correct
12 Correct 122 ms 7468 KB Output is correct
13 Correct 130 ms 9160 KB Output is correct
14 Correct 150 ms 10972 KB Output is correct
15 Correct 144 ms 11180 KB Output is correct
16 Correct 135 ms 9900 KB Output is correct
17 Correct 133 ms 11580 KB Output is correct
18 Correct 138 ms 10088 KB Output is correct
19 Correct 120 ms 12716 KB Output is correct
20 Correct 104 ms 7980 KB Output is correct
21 Correct 94 ms 7596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 87 ms 6196 KB Output is correct
12 Correct 122 ms 7468 KB Output is correct
13 Correct 130 ms 9160 KB Output is correct
14 Correct 150 ms 10972 KB Output is correct
15 Correct 144 ms 11180 KB Output is correct
16 Correct 135 ms 9900 KB Output is correct
17 Correct 133 ms 11580 KB Output is correct
18 Correct 138 ms 10088 KB Output is correct
19 Correct 120 ms 12716 KB Output is correct
20 Correct 104 ms 7980 KB Output is correct
21 Correct 94 ms 7596 KB Output is correct
22 Correct 184 ms 12700 KB Output is correct
23 Correct 194 ms 11184 KB Output is correct
24 Correct 199 ms 11180 KB Output is correct
25 Correct 183 ms 15860 KB Output is correct
26 Correct 175 ms 12204 KB Output is correct
27 Correct 176 ms 11276 KB Output is correct
28 Correct 81 ms 3756 KB Output is correct
29 Correct 157 ms 8664 KB Output is correct
30 Correct 233 ms 8848 KB Output is correct
31 Correct 169 ms 9132 KB Output is correct
32 Correct 165 ms 11612 KB Output is correct