답안 #771525

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771525 2023-07-03T05:52:20 Z ttamx One-Way Streets (CEOI17_oneway) C++14
100 / 100
47 ms 12080 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")

using namespace std;

const int N=1e5+5;

int n,m,p; 
int val[N],val2[N];
char ans[N];
vector<pair<int,int>> adj[N];
bool vis[N],used[N];

void dfs(int u){
    vis[u]=true;
    for(auto [v,i]:adj[u]){
        if(used[i>>1])continue;
        used[i>>1]=true;
        if(!vis[v]){
            dfs(v);
            if(val2[v]>0||!val[v])ans[i>>1]='B';
            else ans[i>>1]=((val[v]>0)^(i&1))?'L':'R';
            val[u]+=val[v];
            val2[u]+=val2[v];
        }else{
            ans[i>>1]='B';
            val2[u]++;
            val2[v]--;
        }
    }
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        int u,v;
        cin >> u >> v;
        adj[u].emplace_back(v,i<<1);
        adj[v].emplace_back(u,i<<1|1);
    }
    cin >> p;
    for(int i=1;i<=p;i++){
        int u,v;
        cin >> u >> v;
        val[u]++;
        val[v]--;
    }
    for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
    for(int i=1;i<=m;i++)cout << ans[i];
}

Compilation message

oneway.cpp: In function 'void dfs(int)':
oneway.cpp:16:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |     for(auto [v,i]:adj[u]){
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 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 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 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 26 ms 7076 KB Output is correct
12 Correct 33 ms 7816 KB Output is correct
13 Correct 30 ms 8888 KB Output is correct
14 Correct 32 ms 9452 KB Output is correct
15 Correct 34 ms 9356 KB Output is correct
16 Correct 36 ms 7548 KB Output is correct
17 Correct 27 ms 9044 KB Output is correct
18 Correct 30 ms 7560 KB Output is correct
19 Correct 28 ms 10232 KB Output is correct
20 Correct 35 ms 7372 KB Output is correct
21 Correct 25 ms 7124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 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 26 ms 7076 KB Output is correct
12 Correct 33 ms 7816 KB Output is correct
13 Correct 30 ms 8888 KB Output is correct
14 Correct 32 ms 9452 KB Output is correct
15 Correct 34 ms 9356 KB Output is correct
16 Correct 36 ms 7548 KB Output is correct
17 Correct 27 ms 9044 KB Output is correct
18 Correct 30 ms 7560 KB Output is correct
19 Correct 28 ms 10232 KB Output is correct
20 Correct 35 ms 7372 KB Output is correct
21 Correct 25 ms 7124 KB Output is correct
22 Correct 39 ms 9052 KB Output is correct
23 Correct 38 ms 7424 KB Output is correct
24 Correct 47 ms 7464 KB Output is correct
25 Correct 40 ms 12080 KB Output is correct
26 Correct 38 ms 8612 KB Output is correct
27 Correct 38 ms 7600 KB Output is correct
28 Correct 22 ms 5032 KB Output is correct
29 Correct 38 ms 6948 KB Output is correct
30 Correct 42 ms 7116 KB Output is correct
31 Correct 40 ms 7500 KB Output is correct
32 Correct 36 ms 9344 KB Output is correct