제출 #250644

#제출 시각아이디문제언어결과실행 시간메모리
250644opukittpceno_hhr어르신 집배원 (BOI14_postmen)C++17
38 / 100
46 ms7800 KiB
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <cmath> #include <cstdio> #include <iomanip> #include <fstream> #include <cassert> #include <cstring> #include <unordered_set> #include <unordered_map> #include <numeric> #include <ctime> #include <bitset> #include <complex> #include <chrono> #include <random> #include <functional> using namespace std; const int N = 2002; struct Edge { int u, v; int alive; Edge() {} Edge(int u_, int v_) { u = u_; v = v_; alive = 1; } }; vector<Edge> ed; vector<int> g[N]; vector<int> et; void dfs(int cur) { while (!g[cur].empty()) { if (ed[g[cur].back()].alive) { ed[g[cur].back()].alive = 0; int v = ed[g[cur].back()].u; if (v == cur) { v = ed[g[cur].back()].v; } dfs(v); } else { g[cur].pop_back(); } } et.push_back(cur); } int in[N]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; ed.resize(m); for (int i = 0; i < m; i++) { cin >> ed[i].u >> ed[i].v; ed[i].alive = 1; ed[i].u--; ed[i].v--; g[ed[i].u].push_back(i); g[ed[i].v].push_back(i); } dfs(0); vector<int> st; for (auto t : et) { if (in[t] > 0) { vector<int> c; while (true) { int br = (st.back() == t); in[st.back()]--; c.push_back(st.back()); st.pop_back(); if (br) break; } for (auto x : c) { cout << x + 1 << ' '; } cout << '\n'; in[t]++; st.push_back(t); } else { in[t]++; st.push_back(t); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...