Submission #140456

#TimeUsernameProblemLanguageResultExecution timeMemory
140456evpipisOne-Way Streets (CEOI17_oneway)C++11
100 / 100
104 ms15996 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back typedef pair<int, int> ii; const int len = 1e5+5; int out[len], num[len], low[len], par[len], sum[len], cnt; ii edge[len]; vector<ii> adj[len]; void dfs(int u){ num[u] = low[u] = ++cnt; for (int j = 0; j < adj[u].size(); j++){ ii v = adj[u][j]; if (!num[v.fi]){ par[v.fi] = v.se; dfs(v.fi); if (low[v.fi] > num[u]){ if (sum[v.fi] > 0) out[v.se] = edge[v.se].fi==v.fi?1:-1; if (sum[v.fi] < 0) out[v.se] = edge[v.se].fi==u?1:-1; } low[u] = min(low[u], low[v.fi]); sum[u] += sum[v.fi]; } else if (v.se != par[u]){ low[u] = min(low[u], num[v.fi]); } } } int main(){ int n, m, q; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++){ int a, b; scanf("%d %d", &a, &b); edge[i] = mp(a, b); adj[a].pb(mp(b, i)); adj[b].pb(mp(a, i)); } scanf("%d", &q); while (q--){ int a, b; scanf("%d %d", &a, &b); sum[a]++; sum[b]--; } for (int i = 1; i <= n; i++) if (!num[i]) dfs(i); for (int i = 0; i < m; i++){ if (out[i] > 0) printf("R"); else if (out[i] == 0) printf("B"); else printf("L"); } printf("\n"); return 0; }

Compilation message (stderr)

oneway.cpp: In function 'void dfs(int)':
oneway.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j < adj[u].size(); j++){
                     ~~^~~~~~~~~~~~~~~
oneway.cpp: In function 'int main()':
oneway.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
oneway.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~
oneway.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
oneway.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...