제출 #636293

#제출 시각아이디문제언어결과실행 시간메모리
636293tvladm2009어르신 집배원 (BOI14_postmen)C++14
38 / 100
1100 ms25520 KiB
#include <iostream> #include <vector> using namespace std; const int MAX_N = 5 * 1e5; int in[MAX_N + 1], out[MAX_N + 1]; vector<int> g[MAX_N + 1], aux; bool viz[MAX_N + 1], b[MAX_N + 1]; int n, m; void dfs(int u) { for (int v : g[u]) { if (!viz[v]) { viz[v] = true; dfs(in[v] ^ out[v] ^ u); aux.push_back(u); } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { cin >> in[i] >> out[i]; in[i]--; out[i]--; g[in[i]].push_back(i); g[out[i]].push_back(i); } aux.push_back(0); dfs(0); vector<int> sol; for (int it : aux) { if (b[it] == true) { while (b[it] == true) { cout << sol.back() + 1 << " "; b[sol.back()] = false; sol.pop_back(); } cout << "\n"; } b[it] = true; sol.push_back(it); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...