#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int N, M, Q;
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]{}, D[N]{}, T[N], t=0;
char S[M+1];
cin>>Q;
while(Q--) {
int i, j;
cin>>i>>j; --i, --j;
++D[i], --D[j];
}
fill(S, S+M, 'B');
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]);
D[i]+=D[j];
if(A[i]<T[j] && D[j]) S[e-2>>1]=(e&1 ? -D[j] : D[j])>0 ? 'L' : 'R';
}
};
for(int i=0; i<N; i++) if(!A[i]) bcc(i, 0);
S[M]=0;
cout<<S<<'\n';
}
Compilation message
oneway.cpp: In lambda function:
oneway.cpp:33:29: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
33 | if(A[i]<T[j] && D[j]) S[e-2>>1]=(e&1 ? -D[j] : D[j])>0 ? 'L' : 'R';
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
25 ms |
3724 KB |
Output is correct |
12 |
Correct |
24 ms |
4620 KB |
Output is correct |
13 |
Correct |
26 ms |
5544 KB |
Output is correct |
14 |
Correct |
28 ms |
6028 KB |
Output is correct |
15 |
Correct |
31 ms |
6188 KB |
Output is correct |
16 |
Correct |
26 ms |
3532 KB |
Output is correct |
17 |
Correct |
25 ms |
5588 KB |
Output is correct |
18 |
Correct |
25 ms |
3540 KB |
Output is correct |
19 |
Correct |
24 ms |
6996 KB |
Output is correct |
20 |
Correct |
25 ms |
5256 KB |
Output is correct |
21 |
Correct |
26 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
25 ms |
3724 KB |
Output is correct |
12 |
Correct |
24 ms |
4620 KB |
Output is correct |
13 |
Correct |
26 ms |
5544 KB |
Output is correct |
14 |
Correct |
28 ms |
6028 KB |
Output is correct |
15 |
Correct |
31 ms |
6188 KB |
Output is correct |
16 |
Correct |
26 ms |
3532 KB |
Output is correct |
17 |
Correct |
25 ms |
5588 KB |
Output is correct |
18 |
Correct |
25 ms |
3540 KB |
Output is correct |
19 |
Correct |
24 ms |
6996 KB |
Output is correct |
20 |
Correct |
25 ms |
5256 KB |
Output is correct |
21 |
Correct |
26 ms |
4480 KB |
Output is correct |
22 |
Correct |
53 ms |
5560 KB |
Output is correct |
23 |
Correct |
48 ms |
3676 KB |
Output is correct |
24 |
Correct |
41 ms |
3524 KB |
Output is correct |
25 |
Correct |
51 ms |
9236 KB |
Output is correct |
26 |
Correct |
40 ms |
5056 KB |
Output is correct |
27 |
Correct |
44 ms |
3796 KB |
Output is correct |
28 |
Correct |
31 ms |
1964 KB |
Output is correct |
29 |
Correct |
41 ms |
4992 KB |
Output is correct |
30 |
Correct |
40 ms |
4404 KB |
Output is correct |
31 |
Correct |
43 ms |
6212 KB |
Output is correct |
32 |
Correct |
44 ms |
6652 KB |
Output is correct |