제출 #631166

#제출 시각아이디문제언어결과실행 시간메모리
631166NintsiChkhaidzeOne-Way Streets (CEOI17_oneway)C++14
0 / 100
3 ms2772 KiB
#include <bits/stdc++.h> #define s second #define f first #define pb push_back using namespace std; const int N = 100005; vector <pair<int,int> > v[N]; int tin[N],low[N],a[N],b[N],open[N],close[N]; bool bridge[N],vis[N],F[N]; int f[N],o,c,cnt; void dfs(int x,int par){ f[x] = 1; tin[x] = low[x] = cnt++; for (auto [to,id]: v[x]){ if (to == par) continue; if (f[to]){ low[x] = min(low[x], tin[to]); }else{ dfs(to,x); low[x] = min(low[x], low[to]); if (low[to] > tin[x]) bridge[id] = 1; } } } void DFS(int x){ vis[x] = 1; if (open[x]) { o++; f[open[x]]++; if (f[open[x]] == 0) o--,c--; } if (close[x]) { f[close[x]]--; c++; if (f[close[x]] == 0) c--,o--; } for (auto [to,id]: v[x]) if (!vis[to] && !F[to]) DFS(to); } int main (){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n,m; cin>>n>>m; for (int i = 1; i <= m; i++){ cin>>a[i]>>b[i]; v[a[i]].pb({b[i],i}); v[b[i]].pb({a[i],i}); } for (int i= 1; i <= n; i++) if (!f[i]) dfs(i,i); int k; cin>>k; for (int i = 1; i <= k; i++){ int x,y; cin>>x>>y; open[x] = i; close[y] = i; } for (int i = 1; i <= m; i++){ if (bridge[i] == 0) cout<<'B'; else{ o = 0,c=0; for (int j=1;j<=n;j++) f[j] = 0,vis[j] = 0; F[b[i]] = 1;DFS(a[i]); F[b[i]] = 0; if(o && !c) cout<<'R'; else if (!o && c) cout<<'L'; else cout<<'B'; } } }

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

oneway.cpp: In function 'void dfs(int, int)':
oneway.cpp:16:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |     for (auto [to,id]: v[x]){
      |               ^
oneway.cpp: In function 'void DFS(int)':
oneway.cpp:42:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |     for (auto [to,id]: v[x])
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...