#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int n,m,p;
pii keep[100005];
pii edge[100005],sol[100005];
vector<pii> muchii[100005];
int topar[100005];
int par[100005];
bool use[100005];
int nr1[100005],nr2[100005];
int niv[100005],nivmin[100005];
int root=1;
void dfs(int nod)
{
use[nod]=1;
if(nod==root)
niv[nod]=1;
nivmin[nod]=niv[nod];
for(auto i:muchii[nod])
{
int a=i.first;
int index=i.second;
if(index==topar[nod])
continue;
if(!use[a])
{
niv[a]=niv[nod]+1;
topar[a]=index;
dfs(a);
nr1[nod]+=nr1[a];
nr2[nod]+=nr2[a];
if(nivmin[a]<=niv[nod])
sol[index]={-1,-1};
else
{
if(nr1[a]>nr2[a])
sol[index]={a,nod};
if(nr1[a]<nr2[a])
sol[index]={nod,a};
if(nr1[a]==nr2[a])
sol[index]={-1,-1};
}
nivmin[nod]=min(nivmin[nod],nivmin[a]);
}
else
{
sol[index]={-1,-1};
nivmin[nod]=min(nivmin[nod],niv[a]);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int a,b;
cin>>a>>b;
edge[i]={a,b};
muchii[a].push_back({b,i});
muchii[b].push_back({a,i});
}
cin>>p;
for(int i=1;i<=p;i++)
{
cin>>keep[i].first>>keep[i].second;
int a=keep[i].first;
int b=keep[i].second;
nr1[a]++;
nr2[b]++;
}
for(int i=1;i<=n;i++)
if(!use[i])
{
root=i;
dfs(root);
}
for(int i=1;i<=m;i++)
{
if(sol[i].first==-1)
cout<<"B";
else
if(sol[i].first==edge[i].first)
cout<<"R";
else
cout<<"L";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2772 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
2 ms |
2772 KB |
Output is correct |
10 |
Correct |
2 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2772 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
2 ms |
2772 KB |
Output is correct |
10 |
Correct |
2 ms |
2772 KB |
Output is correct |
11 |
Correct |
36 ms |
10060 KB |
Output is correct |
12 |
Correct |
36 ms |
11084 KB |
Output is correct |
13 |
Correct |
42 ms |
12356 KB |
Output is correct |
14 |
Correct |
50 ms |
13388 KB |
Output is correct |
15 |
Correct |
50 ms |
13368 KB |
Output is correct |
16 |
Correct |
45 ms |
11176 KB |
Output is correct |
17 |
Correct |
44 ms |
13260 KB |
Output is correct |
18 |
Correct |
47 ms |
11228 KB |
Output is correct |
19 |
Correct |
43 ms |
14468 KB |
Output is correct |
20 |
Correct |
37 ms |
10712 KB |
Output is correct |
21 |
Correct |
35 ms |
10444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2772 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
2 ms |
2772 KB |
Output is correct |
10 |
Correct |
2 ms |
2772 KB |
Output is correct |
11 |
Correct |
36 ms |
10060 KB |
Output is correct |
12 |
Correct |
36 ms |
11084 KB |
Output is correct |
13 |
Correct |
42 ms |
12356 KB |
Output is correct |
14 |
Correct |
50 ms |
13388 KB |
Output is correct |
15 |
Correct |
50 ms |
13368 KB |
Output is correct |
16 |
Correct |
45 ms |
11176 KB |
Output is correct |
17 |
Correct |
44 ms |
13260 KB |
Output is correct |
18 |
Correct |
47 ms |
11228 KB |
Output is correct |
19 |
Correct |
43 ms |
14468 KB |
Output is correct |
20 |
Correct |
37 ms |
10712 KB |
Output is correct |
21 |
Correct |
35 ms |
10444 KB |
Output is correct |
22 |
Correct |
67 ms |
14992 KB |
Output is correct |
23 |
Correct |
64 ms |
13060 KB |
Output is correct |
24 |
Correct |
67 ms |
13136 KB |
Output is correct |
25 |
Correct |
68 ms |
18584 KB |
Output is correct |
26 |
Correct |
63 ms |
14596 KB |
Output is correct |
27 |
Correct |
65 ms |
13224 KB |
Output is correct |
28 |
Correct |
29 ms |
8396 KB |
Output is correct |
29 |
Correct |
56 ms |
12192 KB |
Output is correct |
30 |
Correct |
52 ms |
12360 KB |
Output is correct |
31 |
Correct |
53 ms |
12788 KB |
Output is correct |
32 |
Correct |
54 ms |
15020 KB |
Output is correct |