Submission #771520

# Submission time Handle Problem Language Result Execution time Memory
771520 2023-07-03T05:47:41 Z ttamx One-Way Streets (CEOI17_oneway) C++14
100 / 100
52 ms 12080 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){
    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]==0)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:15:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for(auto [v,i]:adj[u]){
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2724 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2724 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 25 ms 7004 KB Output is correct
12 Correct 35 ms 7900 KB Output is correct
13 Correct 36 ms 8836 KB Output is correct
14 Correct 36 ms 9328 KB Output is correct
15 Correct 30 ms 9328 KB Output is correct
16 Correct 32 ms 7512 KB Output is correct
17 Correct 38 ms 9048 KB Output is correct
18 Correct 30 ms 7508 KB Output is correct
19 Correct 41 ms 10224 KB Output is correct
20 Correct 30 ms 7344 KB Output is correct
21 Correct 31 ms 7144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2724 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 25 ms 7004 KB Output is correct
12 Correct 35 ms 7900 KB Output is correct
13 Correct 36 ms 8836 KB Output is correct
14 Correct 36 ms 9328 KB Output is correct
15 Correct 30 ms 9328 KB Output is correct
16 Correct 32 ms 7512 KB Output is correct
17 Correct 38 ms 9048 KB Output is correct
18 Correct 30 ms 7508 KB Output is correct
19 Correct 41 ms 10224 KB Output is correct
20 Correct 30 ms 7344 KB Output is correct
21 Correct 31 ms 7144 KB Output is correct
22 Correct 43 ms 9040 KB Output is correct
23 Correct 48 ms 7480 KB Output is correct
24 Correct 44 ms 7468 KB Output is correct
25 Correct 43 ms 12080 KB Output is correct
26 Correct 52 ms 8616 KB Output is correct
27 Correct 39 ms 7516 KB Output is correct
28 Correct 34 ms 5064 KB Output is correct
29 Correct 40 ms 7020 KB Output is correct
30 Correct 38 ms 7176 KB Output is correct
31 Correct 43 ms 7492 KB Output is correct
32 Correct 43 ms 9332 KB Output is correct