답안 #230123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230123 2020-05-08T14:09:41 Z islingr One-Way Streets (CEOI17_oneway) C++14
100 / 100
115 ms 37344 KB
#include <iostream>
#include <vector>
using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(x, v) for (auto &x : v)

#define eb(x...) emplace_back(x)

template<class T> bool ckmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

constexpr int N = 1 << 20, M = 1 << 20;
int n, m;
vector<int> g[N];
char ans[M];
int tin[N], low[N], l[M], r[M], s[N], timer;

void dfs(int u, int p = -1) {
	low[u] = tin[u] = ++timer;
	trav(e, g[u]) {
		if (e == p) continue;
		int v = l[e] + r[e] - u;
		if (tin[v]) ckmin(low[u], tin[v]);
		else {
			dfs(v, e);
			ckmin(low[u], low[v]);
			if (tin[u] < low[v]) {
				if (s[v] == 0) continue;
				ans[e] = l[e] == u ? 'L' : 'R';
				if (s[v] < 0) ans[e] = 'L' + 'R' - ans[e];
			}
			s[u] += s[v];
		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> n >> m;
	rep(i, 0, m) {
		cin >> l[i] >> r[i]; --l[i]; --r[i];
		g[l[i]].eb(i); g[r[i]].eb(i);
		ans[i] = 'B';
	}
	int q; cin >> q;
	while (q--) {
		int u, v; cin >> u >> v; --u; --v;
		++s[u]; --s[v];
	}
	rep(u, 0, n) if (!tin[u]) dfs(u);
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 24960 KB Output is correct
2 Correct 20 ms 24960 KB Output is correct
3 Correct 19 ms 25088 KB Output is correct
4 Correct 20 ms 25088 KB Output is correct
5 Correct 20 ms 25088 KB Output is correct
6 Correct 19 ms 25088 KB Output is correct
7 Correct 29 ms 25088 KB Output is correct
8 Correct 20 ms 25088 KB Output is correct
9 Correct 21 ms 25088 KB Output is correct
10 Correct 26 ms 25088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 24960 KB Output is correct
2 Correct 20 ms 24960 KB Output is correct
3 Correct 19 ms 25088 KB Output is correct
4 Correct 20 ms 25088 KB Output is correct
5 Correct 20 ms 25088 KB Output is correct
6 Correct 19 ms 25088 KB Output is correct
7 Correct 29 ms 25088 KB Output is correct
8 Correct 20 ms 25088 KB Output is correct
9 Correct 21 ms 25088 KB Output is correct
10 Correct 26 ms 25088 KB Output is correct
11 Correct 59 ms 30048 KB Output is correct
12 Correct 64 ms 31084 KB Output is correct
13 Correct 88 ms 32120 KB Output is correct
14 Correct 95 ms 32888 KB Output is correct
15 Correct 98 ms 33016 KB Output is correct
16 Correct 93 ms 31352 KB Output is correct
17 Correct 86 ms 33144 KB Output is correct
18 Correct 89 ms 31608 KB Output is correct
19 Correct 77 ms 34376 KB Output is correct
20 Correct 74 ms 30884 KB Output is correct
21 Correct 71 ms 30584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 24960 KB Output is correct
2 Correct 20 ms 24960 KB Output is correct
3 Correct 19 ms 25088 KB Output is correct
4 Correct 20 ms 25088 KB Output is correct
5 Correct 20 ms 25088 KB Output is correct
6 Correct 19 ms 25088 KB Output is correct
7 Correct 29 ms 25088 KB Output is correct
8 Correct 20 ms 25088 KB Output is correct
9 Correct 21 ms 25088 KB Output is correct
10 Correct 26 ms 25088 KB Output is correct
11 Correct 59 ms 30048 KB Output is correct
12 Correct 64 ms 31084 KB Output is correct
13 Correct 88 ms 32120 KB Output is correct
14 Correct 95 ms 32888 KB Output is correct
15 Correct 98 ms 33016 KB Output is correct
16 Correct 93 ms 31352 KB Output is correct
17 Correct 86 ms 33144 KB Output is correct
18 Correct 89 ms 31608 KB Output is correct
19 Correct 77 ms 34376 KB Output is correct
20 Correct 74 ms 30884 KB Output is correct
21 Correct 71 ms 30584 KB Output is correct
22 Correct 109 ms 34312 KB Output is correct
23 Correct 115 ms 32764 KB Output is correct
24 Correct 109 ms 32692 KB Output is correct
25 Correct 99 ms 37344 KB Output is correct
26 Correct 103 ms 33912 KB Output is correct
27 Correct 108 ms 32888 KB Output is correct
28 Correct 52 ms 28280 KB Output is correct
29 Correct 88 ms 31608 KB Output is correct
30 Correct 93 ms 31868 KB Output is correct
31 Correct 94 ms 32120 KB Output is correct
32 Correct 93 ms 34168 KB Output is correct