Submission #510231

#TimeUsernameProblemLanguageResultExecution timeMemory
510231MOUF_MAHMALATOne-Way Streets (CEOI17_oneway)C++14
0 / 100
1 ms328 KiB
#include<bits/stdc++.h> #define all(s) s.begin(),s.end() #define F first #define S second using namespace std; typedef int ll; ll n,m,q,h[100009],low[100009],x,y,t,c[2][100009]; vector<vector<ll> >v; bool b[100009]; pair<ll,ll>p[100009]; map<pair<ll,ll>,char>mp; void go(ll d,ll p) { b[d]=1; for(auto z:v[d]) if(!b[z]) { go(z,d); c[0][d]+=c[0][z]; c[1][d]+=c[1][z]; } } void dfs(ll d,ll p) { h[d]=low[d]=t++; b[d]=1; for(auto z:v[d]) { if(!b[z]) { dfs(z,d); low[d]=min(low[d],low[z]); if(low[z]>h[d]) { if(c[0][d]>c[0][z]&&c[1][z]) mp[ {d,z}]='R',mp[ {z,d}]='L'; else if(c[1][d]>c[1][z]&&c[0][z]) mp[ {d,z}]='L',mp[ {z,d}]='R'; else mp[ {d,z}]=mp[ {d,z}]='B'; } } else if(z!=p) { low[d]=min(low[d],h[z]); mp[ {z,d}]=mp[ {d,z}]='B'; } else mp[{z,d}]=mp[{d,z}]='B'; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n>>m; v.resize(n+1); for(ll i=1; i<=m; i++) { cin>>x>>y; p[i]= {x,y}; v[x].push_back(y); v[y].push_back(x); } cin>>q; while(q--) { cin>>x>>y; c[0][x]=1; c[1][y]=1; } go(1,1); memset(b,0,sizeof b); dfs(1,1); for(ll i=1; i<=m; i++) { if(p[i].F==p[i].S) cout<<"B"; else cout<<mp[p[i]]; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...