# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
995011 | 2024-06-08T10:28:13 Z | NoLove | One-Way Streets (CEOI17_oneway) | C++14 | 46 ms | 21256 KB |
/** * author : Lăng Trọng Đạt * created: 08-06-2024 **/ #include <bits/stdc++.h> using namespace std; #ifndef LANG_DAT #define db(...) ; #endif // LANG_DAT #define int long long #define mp make_pair #define f first #define se second #define pb push_back #define all(v) (v).begin(), (v).end() using pii = pair<int, int>; using vi = vector<int>; #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++) void mx(int& a, int b) { if (b > a) a = b; } void mi(int& a, int b) { if (b < a) a = b; } #define si(x) (int)(x.size()) const int INF = 1e18; const int MOD = 1e9 + 7; const int MAXN = 1e5 + 5; vector<pii> adj[MAXN]; vector<pii> edges; int n, m, a, b, p; int res[MAXN]; // 0 is b, 1 is r, 2 is l int cnt[MAXN], low[MAXN], id[MAXN], d[MAXN]; int timer = 1; void dfs(int v, int prv) { db(v, prv) low[v] = id[v] = timer++; bool multi_edge = false; for (auto[u, i] : adj[v]) { if (u == prv && !multi_edge) { multi_edge = true; continue; } if (id[u]) mi(low[v], id[u]); else { d[u] = d[v] + 1; dfs(u, v); cnt[v] += cnt[u]; mi(low[v], low[u]); if (id[v] < low[u]) { if (cnt[u] == 0) continue; db(u, v, cnt[u], edges[i]) if (cnt[u] > 0) { // u -> v res[i] = (v == edges[i].f ? 2 : 1); } else { // v -> u res[i] = (v == edges[i].se ? 2 : 1); } } } } } int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("hi.inp", "r")) { freopen("hi.inp", "r", stdin); // freopen("hi.out", "w", stdout); } cin >> n >> m; FOR(i, 0, m - 1) { cin >> a >> b; edges.pb({a, b}); adj[a].pb({b, i}); adj[b].pb({a, i}); } cin >> p; FOR(i, 1, p) { cin >> a >> b; cnt[a]++; cnt[b]--; } FOR(i, 1, n) { if (!id[i]) { dfs(i, -1); } } db(n, m, p) FOR(i, 0, m - 1) { if (res[i] == 0) cout << 'B'; else cout << (res[i] == 1 ? 'R' : 'L'); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 2 ms | 4444 KB | Output is correct |
8 | Correct | 2 ms | 4444 KB | Output is correct |
9 | Correct | 2 ms | 4444 KB | Output is correct |
10 | Correct | 2 ms | 4444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 2 ms | 4444 KB | Output is correct |
8 | Correct | 2 ms | 4444 KB | Output is correct |
9 | Correct | 2 ms | 4444 KB | Output is correct |
10 | Correct | 2 ms | 4444 KB | Output is correct |
11 | Correct | 26 ms | 14028 KB | Output is correct |
12 | Correct | 33 ms | 15308 KB | Output is correct |
13 | Correct | 32 ms | 16324 KB | Output is correct |
14 | Correct | 35 ms | 17092 KB | Output is correct |
15 | Correct | 36 ms | 17084 KB | Output is correct |
16 | Correct | 37 ms | 14532 KB | Output is correct |
17 | Correct | 35 ms | 16576 KB | Output is correct |
18 | Correct | 31 ms | 14536 KB | Output is correct |
19 | Correct | 32 ms | 17864 KB | Output is correct |
20 | Correct | 27 ms | 14536 KB | Output is correct |
21 | Correct | 26 ms | 14276 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 2 ms | 4444 KB | Output is correct |
8 | Correct | 2 ms | 4444 KB | Output is correct |
9 | Correct | 2 ms | 4444 KB | Output is correct |
10 | Correct | 2 ms | 4444 KB | Output is correct |
11 | Correct | 26 ms | 14028 KB | Output is correct |
12 | Correct | 33 ms | 15308 KB | Output is correct |
13 | Correct | 32 ms | 16324 KB | Output is correct |
14 | Correct | 35 ms | 17092 KB | Output is correct |
15 | Correct | 36 ms | 17084 KB | Output is correct |
16 | Correct | 37 ms | 14532 KB | Output is correct |
17 | Correct | 35 ms | 16576 KB | Output is correct |
18 | Correct | 31 ms | 14536 KB | Output is correct |
19 | Correct | 32 ms | 17864 KB | Output is correct |
20 | Correct | 27 ms | 14536 KB | Output is correct |
21 | Correct | 26 ms | 14276 KB | Output is correct |
22 | Correct | 44 ms | 17596 KB | Output is correct |
23 | Correct | 45 ms | 15812 KB | Output is correct |
24 | Correct | 41 ms | 15672 KB | Output is correct |
25 | Correct | 41 ms | 21256 KB | Output is correct |
26 | Correct | 43 ms | 17256 KB | Output is correct |
27 | Correct | 46 ms | 15812 KB | Output is correct |
28 | Correct | 22 ms | 11456 KB | Output is correct |
29 | Correct | 40 ms | 15300 KB | Output is correct |
30 | Correct | 40 ms | 15552 KB | Output is correct |
31 | Correct | 39 ms | 15808 KB | Output is correct |
32 | Correct | 38 ms | 18124 KB | Output is correct |