#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define ll long long
#define int long long
const long long inf=1e18;
const int MOD=1e9+7;
const int N=1001;
int n,m;
set<int> adj[N];
bool vis[N],ans=0; //pos1=Right po2=Left
int pos1[N],pos2[N];
void func(int node,int goal){
if(node==goal || ans){
ans=1;
return;
}
for(auto i:adj[node]){
if(!vis[i]){
vis[i]=1;
func(i,goal);
}
}
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
pair<int,int> a[m];
for(int i=0;i<m;i++){
int x,y; cin>>x>>y;
a[i].first=x; a[i].second=y;
adj[x].insert(y);
adj[y].insert(x);
}
int p; cin>>p;
int fr=p;
while(p--){
int st,en; cin>>st>>en;
for(int i=0;i<m;i++){
int x=a[i].first,y=a[i].second;
adj[y].erase(x);
func(st,en);
for(int j=0;j<=n;j++)vis[j]=0;
if(ans)pos1[i]++;
ans=0;
adj[y].insert(x);
adj[x].erase(y);
func(st,en);
for(int j=0;j<=n;j++)vis[j]=0;
if(ans)pos2[i]++;
ans=0;
adj[x].insert(y);
}
}
for(int i=0;i<m;i++){
if(pos1[i]==fr && pos2[i]==fr)cout<<'B';
else if(pos1[i]==fr)cout<<'R';
else cout<<'L';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
136 ms |
632 KB |
Output is correct |
4 |
Correct |
54 ms |
604 KB |
Output is correct |
5 |
Correct |
1304 ms |
604 KB |
Output is correct |
6 |
Correct |
10 ms |
604 KB |
Output is correct |
7 |
Correct |
1333 ms |
628 KB |
Output is correct |
8 |
Correct |
1209 ms |
612 KB |
Output is correct |
9 |
Incorrect |
953 ms |
600 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
136 ms |
632 KB |
Output is correct |
4 |
Correct |
54 ms |
604 KB |
Output is correct |
5 |
Correct |
1304 ms |
604 KB |
Output is correct |
6 |
Correct |
10 ms |
604 KB |
Output is correct |
7 |
Correct |
1333 ms |
628 KB |
Output is correct |
8 |
Correct |
1209 ms |
612 KB |
Output is correct |
9 |
Incorrect |
953 ms |
600 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
136 ms |
632 KB |
Output is correct |
4 |
Correct |
54 ms |
604 KB |
Output is correct |
5 |
Correct |
1304 ms |
604 KB |
Output is correct |
6 |
Correct |
10 ms |
604 KB |
Output is correct |
7 |
Correct |
1333 ms |
628 KB |
Output is correct |
8 |
Correct |
1209 ms |
612 KB |
Output is correct |
9 |
Incorrect |
953 ms |
600 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |