//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 ;
}
}
}
ll cur = p ;
while(cur != o){
ll tmp = par[cur] ;
if(bridg.count({cur , tmp})){
mp[{tmp , cur}] = 1 ;
}
cur = tmp ;
}
}
for(ll i = 1 ; i <= m ; i++){
if(is[i])cout << "B" ;
else if(mp[edj[i]])cout << "R" ;
else if(mp[{edj[i].S , edj[i].F}])cout << "L" ;
else cout << "B" ;
}
cout << endl ;
}
int main(){
fast ;
q = 1 ;
//cin >> q ;
while(q--){
solve() ;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
22092 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
22092 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
22092 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |