이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
using namespace std;
signed main() {
int n, m, p;
cin >> n >> m;
vector<vector<pii>> adj(n + 1, vector<pii>(0));
vector<pii> changes (0);
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
adj[u].pb({v, i});
adj[v].pb({u, i});
}
cin >> p;
for (int i = 0; i < p; i++) {
int l, r;
cin >> l >> r;
changes.pb({l, r});
}
char str[m];
for (int i = 0; i < m; i++) str[i] = 'c';
for (int i = 0; i < p; i++) {
int start = changes[i].fi;
int end = changes[i].se;
if (adj[start].size() == 1) { // R
int ind = adj[start][0].se - 1;
if (str[ind] == 'c') str[ind] = 'R';
else if (str[ind] == 'L') str[ind] = 'B';
}
if (adj[end].size() == 1) { // L
int ind = adj[end][0].se - 1;
if (str[ind] == 'c') str[ind] = 'L';
else if (str[ind] == 'R') str[ind] = 'B';
}
}
string res = "";
for (char c : str) {
if (c == 'c') res += 'B';
else res += c;
}
cout << res << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |