답안 #771498

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771498 2023-07-03T05:26:04 Z ttamx One-Way Streets (CEOI17_oneway) C++14
100 / 100
56 ms 14288 KB
#include<bits/stdc++.h>

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,int p){
    vis[u]=true;
    for(auto [v,i]:adj[u]){
        if(used[abs(i)])continue;
        used[abs(i)]=true;
        if(!vis[v]){
            dfs(v,i);
            if(val2[v]>0||val[v]==0)ans[abs(i)]='B';
            else ans[abs(i)]=((val[v]<0)^(i>0))?'L':'R';
            val[u]+=val[v];
            val2[u]+=val2[v];
        }else{
            ans[abs(i)]='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);
        adj[v].emplace_back(u,-i);
    }
    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,0);
    for(int i=1;i<=m;i++)cout << ans[i];
}

Compilation message

oneway.cpp: In function 'void dfs(int, int)':
oneway.cpp:15:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for(auto [v,i]:adj[u]){
      |              ^
# 결과 실행 시간 메모리 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 2644 KB Output is correct
5 Correct 2 ms 2704 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 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 2 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 2704 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 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 31 ms 8112 KB Output is correct
12 Correct 28 ms 8976 KB Output is correct
13 Correct 36 ms 9932 KB Output is correct
14 Correct 32 ms 10504 KB Output is correct
15 Correct 35 ms 10508 KB Output is correct
16 Correct 42 ms 8732 KB Output is correct
17 Correct 35 ms 10188 KB Output is correct
18 Correct 29 ms 8672 KB Output is correct
19 Correct 29 ms 11368 KB Output is correct
20 Correct 26 ms 8572 KB Output is correct
21 Correct 30 ms 8236 KB Output is correct
# 결과 실행 시간 메모리 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 2644 KB Output is correct
5 Correct 2 ms 2704 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 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 31 ms 8112 KB Output is correct
12 Correct 28 ms 8976 KB Output is correct
13 Correct 36 ms 9932 KB Output is correct
14 Correct 32 ms 10504 KB Output is correct
15 Correct 35 ms 10508 KB Output is correct
16 Correct 42 ms 8732 KB Output is correct
17 Correct 35 ms 10188 KB Output is correct
18 Correct 29 ms 8672 KB Output is correct
19 Correct 29 ms 11368 KB Output is correct
20 Correct 26 ms 8572 KB Output is correct
21 Correct 30 ms 8236 KB Output is correct
22 Correct 43 ms 11300 KB Output is correct
23 Correct 48 ms 9744 KB Output is correct
24 Correct 56 ms 9796 KB Output is correct
25 Correct 42 ms 14288 KB Output is correct
26 Correct 53 ms 10912 KB Output is correct
27 Correct 51 ms 9852 KB Output is correct
28 Correct 23 ms 6180 KB Output is correct
29 Correct 46 ms 9292 KB Output is correct
30 Correct 37 ms 9408 KB Output is correct
31 Correct 48 ms 9692 KB Output is correct
32 Correct 49 ms 11616 KB Output is correct