# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
252022 | win11905 | One-Way Streets (CEOI17_oneway) | C++11 | 2 ms | 2688 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
const int N = 1e5+5;
int n, m, k;
int x[N], y[N];
vector<int> g[N];
bool check[N], checkEdge[N];
char ans[N];
int d1[N], d2[N];
void dfs(int u, int p) {
check[u] = true;
for(int e : g[u]) {
int v = u ^ x[e] ^ y[e];
if(v == p) continue;
if(!check[v]) {
dfs(v, u);
checkEdge[e] = true;
} else {
if(x[e] == u) {
swap(x[e], y[e]);
}
}
}
}
void find_answer(int u, int p) {
check[u] = false;
for(int e : g[u]) if(checkEdge[e]) {
int v = u ^ x[e] ^ y[e];
if(v == p) continue;
ans[e] = 'B';
find_answer(v, u);
d1[u] += d1[v], d2[u] += d2[v];
if(d1[v] || !d2[v]) {
continue;
}
if((d2[v] < 0) ^ (x[e] == u)) {
ans[e] = 'L';
} else {
ans[e] = 'R';
}
}
}
int main() {
scanf("%d %d", &n, &m);
for(int i = 0; i < m; ++i) {
scanf("%d %d", &x[i], &y[i]);
g[x[i]].emplace_back(i), g[y[i]].emplace_back(i);
}
for(int i = 1; i <= n; ++i) if(!check[i]){
dfs(i, 0);
}
for(int i = 0; i < m; ++i) if(!checkEdge[i]) {
ans[i] = 'B';
d1[x[i]]++, d2[y[i]]--;
}
scanf("%d", &k);
for(int i = 0, a, b; i < k; ++i) {
scanf("%d %d", &a, &b);
d2[a]++, d2[b]--;
}
for(int i = 1; i <= n; ++i) if(check[i]) {
find_answer(i, 0);
}
puts(ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |