제출 #938493

#제출 시각아이디문제언어결과실행 시간메모리
938493vjudge1One-Way Streets (CEOI17_oneway)C++17
30 / 100
646 ms604 KiB
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() #define ordered_mset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> const int INF = 1e18,N = 1001; vector<vector<pair<int,int>>> g(N); vector<int> vis(N); void dfs(int n,int wow){ vis[n] = 1; for(auto [v,ind] : g[n]){ if(vis[v] != 1 && wow != ind){ dfs(v,wow); } } } int checkRL(int u,int v,int a,int b,int ind){ for(int j = 0;j < N;j++){ vis[j] = 0; } dfs(u,ind); if(vis[a] == 1){ return 1; } else if(vis[b] == 1){ return 2; } for(int j = 0;j < N;j++){ vis[j] = 0; } dfs(v,ind); if(vis[a] == 1){ return 2; } else if(vis[b] == 1){ return 1; } } void solve(){ int n,m; cin >> n >> m; vector<pair<int,int>> rebro; for(int i = 0;i < m;i++){ int a,b; cin >> a >> b; rebro.pb({a,b}); g[a].pb({b,i}); g[b].pb({a,i}); } vector<pair<int,int>> vip; int p; cin >> p; for(int i = 0;i < p;i++){ int a,b; cin >> a >> b; vip.pb({a,b}); } int i = 0; vector<int> r(m + 1,1),l(m + 1,1); for(auto [u,v] : rebro){ for(auto [fst,scn] : vip){ for(int j = 0;j < N;j++){ vis[j] = 0; } dfs(fst,i); if(vis[scn]){ continue; } int type = checkRL(fst,scn,u,v,i); if(type == 1){ r[i] = 1; l[i] = 0; } if(type == 2){ l[i] = 1; r[i] = 0; } } i++; } string ans = ""; for(int i = 0;i < m;i++){ if(r[i] && l[i]){ ans += 'B'; } else if(r[i]){ ans += 'R'; } else{ ans += 'L'; } } cout << ans << "\n"; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); int t = 1; // cin >> t; while(t--){ solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

oneway.cpp: In function 'long long int checkRL(long long int, long long int, long long int, long long int, long long int)':
oneway.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...