제출 #1080084

#제출 시각아이디문제언어결과실행 시간메모리
1080084jk_Pipes (CEOI15_pipes)C++14
40 / 100
773 ms42836 KiB
#include <bits/stdc++.h> using namespace std; struct ufind { vector<int> c; ufind(int n) : c(n) { iota(c.begin(), c.end(), 0); } int find(int k) { return c[k] == k ? k : (c[k] = find(c[k])); } void unite(int a, int b) { c[find(a)] = find(b); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<pair<int, int>> edges; { array<ufind, 2> msts{{ufind(n), ufind(n)}}; for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a; --b; for (auto& mst : msts) { if (mst.find(a) != mst.find(b)) { mst.unite(a, b); edges.emplace_back(a, b); break; } } } } vector<vector<int>> g(n); for (auto [a, b] : edges) { g[a].push_back(b); g[b].push_back(a); } edges.clear(); vector<bool> visited(n); vector<int> pre(n, -1), low(n, -1); int timer=0; auto dfs = [&](auto&& self, int v, int p = -1) -> void { visited[v] = true; pre[v] = low[v] = timer++; bool used_p = false; for (auto w : g[v]) { if (w == p && !used_p) { used_p = true; continue; } if (visited[w]) { low[v] = min(low[v], pre[w]); } else { self(self, w, v); low[v] = min(low[v], low[w]); if (low[w] > pre[v]) { cout << v+1 << ' ' << w+1 << '\n'; } } } }; for (int i = 0; i < n; ++i) if (!visited[i]) dfs(dfs, i); }

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

pipes.cpp: In function 'int main()':
pipes.cpp:33:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |   for (auto [a, b] : edges) {
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...