#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pii pair<int,int>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define int long long
#define s second
#define pii pair<int,int>
template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;}
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
const int N = 3e5 + 5 ;
const int inf = 1e17 + 7;
const int mod = 998244353;
/*int n,m,k,a,b;
vector<int>g[N];
vector<pii>all;
vector<array<int,2>>vs(N);
void dfs(int x, vector<int>vis, map<pii,int>mp){
if(x == b){
int i = 0;
for(auto to:all){
if(mp[{to.f,to.s}]){
vs[i][1] = 1;
}
if(mp[{to.s,to.f}]){
vs[i][0] = 1;
}
i += 1;
}
}
for(auto to:g[x]){
if(vis[to] > vis[x] + 1){
vis[to] = vis[x] + 1;
mp[{x,to}] = 1;
dfs(to,vis,mp);
}
}
}*/
vector<pii>g[N];
vector<int>vis(1005);
vector<pii>v,vs;
void dfs(int x, int ind){
vis[x] = 1;
for(auto to:g[x]){
if(to.s == ind||vis[to.f])continue;
dfs(to.f,ind);
}
}
bool check(int a, int b, int ind){
for(int i = 0;i<=1000;i++)vis[i] = 0;
dfs(a,ind);
if(vis[b] == 1)return true;
else return false;
}
void solve(){
int n,m,k;
cin>>n>>m;
for(int i = 0;i<m;i++){
int a,b;
cin>>a>>b;
g[a].pb({b,i});
g[b].pb({a,i});
v.pb({a,b});
}
int p;
cin>>p;
for(int i = 1;i<=p;i++){
int a,b;
cin>>a>>b;
vs.pb({a,b});
}
vector<array<int,2>>ans(m + 1);
for(int i = 0;i<m;i++){
ans[i][0] = 1;
ans[i][1] = 1;
int x = v[i].f;
int y = v[i].s;
for(int j = 0;j<p;j++){
int a = vs[j].f;
int b = vs[j].s;
if(check(a,b,i))continue;
//Заебал го
if(!check(a,x,i))ans[i][0] = 0;
if(!check(b,y,i))ans[i][0] = 0;
if(!check(a,y,i))ans[i][1] = 0;
if(!check(b,x,i))ans[i][1] = 0;
}
}
for(int i = 0;i<m;i++){
if(ans[i][0] + ans[i][1] == 2)cout<<"B";
else if(ans[i][0])cout<<"R";
else cout<<"L";
}
}
signed main()
{
// freopen("seq.in", "r", stdin);
// freopen("seq.out", "w", stdout);
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int tt=1;//cin>>tt>>n;
while(tt--)solve();
}
Compilation message
oneway.cpp: In function 'void solve()':
oneway.cpp:77:10: warning: unused variable 'k' [-Wunused-variable]
77 | int n,m,k;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
7256 KB |
Output is correct |
2 |
Correct |
2 ms |
7516 KB |
Output is correct |
3 |
Correct |
81 ms |
7516 KB |
Output is correct |
4 |
Correct |
31 ms |
7512 KB |
Output is correct |
5 |
Correct |
891 ms |
7596 KB |
Output is correct |
6 |
Correct |
429 ms |
7588 KB |
Output is correct |
7 |
Correct |
894 ms |
7592 KB |
Output is correct |
8 |
Correct |
595 ms |
7584 KB |
Output is correct |
9 |
Correct |
499 ms |
7580 KB |
Output is correct |
10 |
Correct |
522 ms |
7572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
7256 KB |
Output is correct |
2 |
Correct |
2 ms |
7516 KB |
Output is correct |
3 |
Correct |
81 ms |
7516 KB |
Output is correct |
4 |
Correct |
31 ms |
7512 KB |
Output is correct |
5 |
Correct |
891 ms |
7596 KB |
Output is correct |
6 |
Correct |
429 ms |
7588 KB |
Output is correct |
7 |
Correct |
894 ms |
7592 KB |
Output is correct |
8 |
Correct |
595 ms |
7584 KB |
Output is correct |
9 |
Correct |
499 ms |
7580 KB |
Output is correct |
10 |
Correct |
522 ms |
7572 KB |
Output is correct |
11 |
Incorrect |
1773 ms |
17312 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
7256 KB |
Output is correct |
2 |
Correct |
2 ms |
7516 KB |
Output is correct |
3 |
Correct |
81 ms |
7516 KB |
Output is correct |
4 |
Correct |
31 ms |
7512 KB |
Output is correct |
5 |
Correct |
891 ms |
7596 KB |
Output is correct |
6 |
Correct |
429 ms |
7588 KB |
Output is correct |
7 |
Correct |
894 ms |
7592 KB |
Output is correct |
8 |
Correct |
595 ms |
7584 KB |
Output is correct |
9 |
Correct |
499 ms |
7580 KB |
Output is correct |
10 |
Correct |
522 ms |
7572 KB |
Output is correct |
11 |
Incorrect |
1773 ms |
17312 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |