Submission #995011

#TimeUsernameProblemLanguageResultExecution timeMemory
995011NoLoveOne-Way Streets (CEOI17_oneway)C++14
100 / 100
46 ms21256 KiB
/** * 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 (stderr)

oneway.cpp: In function 'void dfs(long long int, long long int)':
oneway.cpp:36:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   36 |     for (auto[u, i] : adj[v]) {
      |              ^
oneway.cpp: In function 'int32_t main()':
oneway.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
oneway.cpp:68:5: note: in expansion of macro 'FOR'
   68 |     FOR(i, 0, m - 1) {
      |     ^~~
oneway.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
oneway.cpp:75:5: note: in expansion of macro 'FOR'
   75 |     FOR(i, 1, p) {
      |     ^~~
oneway.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
oneway.cpp:80:5: note: in expansion of macro 'FOR'
   80 |     FOR(i, 1, n) {
      |     ^~~
oneway.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
oneway.cpp:86:5: note: in expansion of macro 'FOR'
   86 |     FOR(i, 0, m - 1) {
      |     ^~~
oneway.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen("hi.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...