This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int N, M;
cin>>N>>M;
int E[M*2+2], F[M*2+2], G[N]{};
for(int i=1; i<=M; i++) {
int a, b;
cin>>a>>b; --a, --b;
E[i*2]=b, F[i*2]=G[a], G[a]=i*2;
E[i*2+1]=a, F[i*2+1]=G[b], G[b]=i*2+1;
}
int A[N]{}, T[N], t=0, v=N, st;
bool U[M+1]{}, V[M+1]{};
cin>>st>>st;
function<void(int, int)> bcc=[&](int i, int p) {
A[i]=T[i]=++t;
for(int e=G[i]; e; e=F[e]) if(e!=p) {
int&j=E[e];
if(A[j]) { T[i]=min(T[i], A[j]); continue; }
bcc(j, e^1);
T[i]=min(T[i], T[j]);
U[p>>1]^=U[e>>1]^=j==st;
U[e>>1]^=e&1;
if(A[i]<T[j]) V[e>>1]=true;
}
};
bcc(0, 0);
for(int i=1; i<=M; i++)
cout<<(V[i] ? U[i] ? 'R' : 'L' : 'B');
}
Compilation message (stderr)
oneway.cpp: In function 'int main()':
oneway.cpp:15:25: warning: unused variable 'v' [-Wunused-variable]
15 | int A[N]{}, T[N], t=0, v=N, st;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |