Submission #509717

# Submission time Handle Problem Language Result Execution time Memory
509717 2022-01-14T08:37:00 Z Blistering_Barnacles One-Way Streets (CEOI17_oneway) C++11
0 / 100
10 ms 22092 KB
//apig's property
//Happiness can be found, even in the darkest of times, if one only remembers to turn on the light
//El Pueblo Unido Jamas Sera Vencido
//Do or do not... there is no try
//Billions of bilious blue blistering barnacles in a thundering typhoon!
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define str string
#define md ((s + e) / 2)
#define mid ((l + r) / 2)
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define C continue
#define R return
#define B break
#define lx node * 2
#define rx node * 2 + 1
#define br(o) o ; break
#define co(o) o ; continue
using namespace std;
typedef long long ll;
ll q, timer , dis[555555] , vis[500005], tin[555555] , low[555555] , par[555555] , k, l, m, n, o, p;
map < pll , ll > mp1 , mp;
vll adj[555555];
const ll mod = 1e9+7;
str s;
ll is[555555] ;
pll edj[555555] ;
map < pll , ll > bridg ;
void dfs(ll v , ll par){
    vis[v] = 1 ;
    low[v] = tin[v] = timer++ ;
    for(auto u : adj[v]){
        if(u == par)C ;
        if(vis[u]){
            low[v] = min(low[v] , tin[u]) ;
            C ;
        }
        dfs(u , v) ;
        low[v] = min(low[v] , low[u]) ;
        if(low[u] > tin[v]){
            bridg[{v , u}] = 1 , bridg[{u , v}] = -1 ;
        }
    }
}
void solve(){
    msdp(tin) , msdp(low) ;
    cin >> n >> m ;
    for(ll i = 1 ; i <= m ; i++){
        cin >> o >> p ;
        edj[i] = {o , p} ;
        mp1[{o , p}]++ ;
        if(o == p || mp1[{o , p}] > 1){
            is[i] = 1 ;
        }
        else {
            adj[o].pb(p) ;
            adj[p].pb(o) ;
        }
    }
    dfs(1 , 0) ;
    cin >> l ;
    for(ll i = 1 ; i <= l ; i++){
        cin >> o >> p ;
        for(ll j = 1 ; j <= n ; j++){
            par[j] = j ;
            dis[j] = 1e15 ;
        }
        dis[o] = 0 ;
        queue < pll > se ;
        se.push({o , 0}) ;
        while(!se.empty()){
            ll v , ds ;
            v = se.front().F ;
            ds = se.front().S ;
            se.pop() ;
            for(auto u : adj[v]){
                if(dis[u] > ds + 1){
                    dis[u] = ds + 1 ;
                    se.push({u , dis[u]}) ;
                    par[u] = v ;
                }
            }
        }
        cout << dis[p] << endl ;
        ll cur = p ;
        while(cur != o){
            ll tmp = par[cur] ;
            if(bridg.count({cur , tmp})){
                mp[{cur , tmp}] = bridg[{cur , tmp}] ;
            }
            cur = tmp ;
        }
    }
    for(ll i = 1 ; i <= m ; i++){
        if(is[i])cout << "B" ;
        else if(mp[edj[i]] == 1)cout << "R" ;
        else if(mp[edj[i]] == -1)cout << "L" ;
        else if(mp[{edj[i].S , edj[i].F}] == 1)cout << "R" ;
        else if(mp[{edj[i].S , edj[i].F}] == -1)cout << "L" ;
        else cout << "B" ;
    }
}
int main(){
    fast ;
    q = 1 ;
    //cin >> q ;
    while(q--){
        solve() ;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 22092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 22092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 22092 KB Output isn't correct
2 Halted 0 ms 0 KB -