Submission #343214

#TimeUsernameProblemLanguageResultExecution timeMemory
343214benedict0724One-Way Streets (CEOI17_oneway)C++17
0 / 100
2013 ms492 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[1002]; pair<int, int> road[1002]; pair<int, int> haveTo[1002]; bool visited[1002]; bool poss = false; void dfs(int x, int s, int e, int g){ visited[x] = true; if(x == g){ poss = true; return; } for(auto u : adj[x]){ if(!visited[u] && (x != e || u != s)){ dfs(u, s, e, g); if(poss) return; } } } int main() { int n, m; scanf("%d %d", &n, &m); for(int i=1;i<=m;i++){ int s, e; scanf("%d %d", &s, &e); adj[s].push_back(e); adj[e].push_back(s); road[i] = {s, e}; } int p; scanf("%d", &p); for(int i=1;i<=p;i++){ int s, e; scanf("%d %d", &s, &e); haveTo[i] = {s, e}; } for(int i=1;i<=m;i++){ int s = road[i].first, e = road[i].second; bool toR = true, toL = true; for(int j=1;j<=p;j++){ for(int k=1;k<=n;k++){ visited[k] = false; } poss = false; dfs(haveTo[j].first, s, e, haveTo[j].second); if(!poss){ toR = false; } for(int k=1;k<=n;k++){ visited[k] = false; } poss = false; dfs(haveTo[j].first, e, s, haveTo[j].second); if(!poss){ toL = false; } } if(toR && toL) printf("B"); else if(toR) printf("R"); else printf("L"); } }

Compilation message (stderr)

oneway.cpp: In function 'int main()':
oneway.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
oneway.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |         scanf("%d %d", &s, &e);
      |         ~~~~~^~~~~~~~~~~~~~~~~
oneway.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |     scanf("%d", &p);
      |     ~~~~~^~~~~~~~~~
oneway.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |         scanf("%d %d", &s, &e);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...