#include <bits/stdc++.h>
#include <fstream>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define mod 1000000007
#define INF 1000000000
#define INF2 2000000000
#define fi first
#define se second
using namespace std;
double const EPS = 1e-14;
const int P = 1007;
typedef long long ll;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
const int Max = 1e5 + 5;
vector<int> v[Max];
int sta[Max], low[Max], par[Max];
int tim = 0, cntx = 0, cnty = 0;
map<pair<int,int>,int> mp, check;
bool vis[Max], ok = false;
int okx[Max], oky[Max];
void dfs(int s, int p) {
tim++;
vis[s] = 1; sta[s] = tim; low[s] = tim;
for(auto i : v[s]) {
if(vis[i] == 0) {
dfs(i,s);
low[s] = min(low[s],low[i]);
okx[s]+=okx[i];
oky[s]+=oky[i];
if(low[i] > sta[s]) {
if(okx[i] > oky[i]) {
mp[{i,s}] = 2;
mp[{s,i}] = 3;
}
else if(okx[i] < oky[i]) {
mp[{s,i}] = 2;
mp[{i,s}] = 3;
}
}
}
else if(i != p || par[s] > 0){
low[s] = min(sta[i],low[s]);
}
else if(i == p) {
par[s]++;
}
}
}
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, m; cin >> n >> m;
pair<int,int> edge[m];
for(int i = 0; i < m; i++) {
int a, b; cin >> a >> b;
edge[i].fi = a, edge[i].se = b;
v[a].push_back(b);
v[b].push_back(a);
}
int p; cin >> p;
while(p--) {
int a, b; cin >> a >> b;
okx[a]++; oky[b]++;
}
for(int i = 1; i <= n; i++) {
if(vis[i] == 0) {
cntx = 0; cnty = 0; dfs(i,0);
}
}
for(int i = 0; i < m; i++) {
if(mp[{edge[i].fi,edge[i].se}] == 0) cout << 'B';
else if(mp[{edge[i].fi,edge[i].se}] == 3) cout << 'L';
else cout << 'R';
}
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2904 KB |
Output is correct |
4 |
Correct |
2 ms |
2904 KB |
Output is correct |
5 |
Correct |
2 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2952 KB |
Output is correct |
7 |
Correct |
2 ms |
4700 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
2 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2904 KB |
Output is correct |
4 |
Correct |
2 ms |
2904 KB |
Output is correct |
5 |
Correct |
2 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2952 KB |
Output is correct |
7 |
Correct |
2 ms |
4700 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
2 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
57 ms |
14416 KB |
Output is correct |
12 |
Correct |
55 ms |
15700 KB |
Output is correct |
13 |
Correct |
56 ms |
18260 KB |
Output is correct |
14 |
Correct |
62 ms |
18868 KB |
Output is correct |
15 |
Correct |
69 ms |
18768 KB |
Output is correct |
16 |
Correct |
59 ms |
16204 KB |
Output is correct |
17 |
Correct |
73 ms |
21076 KB |
Output is correct |
18 |
Correct |
59 ms |
16464 KB |
Output is correct |
19 |
Correct |
79 ms |
22748 KB |
Output is correct |
20 |
Correct |
55 ms |
16608 KB |
Output is correct |
21 |
Correct |
47 ms |
16208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2904 KB |
Output is correct |
4 |
Correct |
2 ms |
2904 KB |
Output is correct |
5 |
Correct |
2 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2952 KB |
Output is correct |
7 |
Correct |
2 ms |
4700 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
2 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
57 ms |
14416 KB |
Output is correct |
12 |
Correct |
55 ms |
15700 KB |
Output is correct |
13 |
Correct |
56 ms |
18260 KB |
Output is correct |
14 |
Correct |
62 ms |
18868 KB |
Output is correct |
15 |
Correct |
69 ms |
18768 KB |
Output is correct |
16 |
Correct |
59 ms |
16204 KB |
Output is correct |
17 |
Correct |
73 ms |
21076 KB |
Output is correct |
18 |
Correct |
59 ms |
16464 KB |
Output is correct |
19 |
Correct |
79 ms |
22748 KB |
Output is correct |
20 |
Correct |
55 ms |
16608 KB |
Output is correct |
21 |
Correct |
47 ms |
16208 KB |
Output is correct |
22 |
Correct |
122 ms |
25684 KB |
Output is correct |
23 |
Correct |
141 ms |
23636 KB |
Output is correct |
24 |
Correct |
125 ms |
23120 KB |
Output is correct |
25 |
Correct |
121 ms |
29872 KB |
Output is correct |
26 |
Correct |
148 ms |
25344 KB |
Output is correct |
27 |
Correct |
120 ms |
23280 KB |
Output is correct |
28 |
Correct |
30 ms |
8028 KB |
Output is correct |
29 |
Correct |
64 ms |
16268 KB |
Output is correct |
30 |
Correct |
58 ms |
16560 KB |
Output is correct |
31 |
Correct |
63 ms |
18008 KB |
Output is correct |
32 |
Correct |
74 ms |
21556 KB |
Output is correct |