제출 #1119619

#제출 시각아이디문제언어결과실행 시간메모리
1119619vjudge1어르신 집배원 (BOI14_postmen)C++17
0 / 100
1 ms592 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long int n, m; vector<vector<pair<int, int>>> a; bool kt[500005]; void get_ans(int u) { vector<int> ans; ans.push_back(u); while (a[u].size()) { auto [v, id] = a[u].back(); a[u].pop_back(); if (kt[id] == true) continue; kt[id] = true; ans.push_back(v); u = v; } ans.pop_back(); for (int i : ans) { cout << i << " "; } if (ans.size()) cout << endl; for (int i : ans) { get_ans(i); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; a.assign(n + 1, {}); for (int i = 1; i <= m; i++) { int u, v; cin >> u >> v; a[u].push_back({v, i}); a[v].push_back({u, i}); } get_ans(1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...