제출 #1119690

#제출 시각아이디문제언어결과실행 시간메모리
1119690sasde어르신 집배원 (BOI14_postmen)C++17
0 / 100
13 ms12124 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; const int maxn = 5e5 + 5; int n, m; vector<pair<int, int>> g[maxn]; vector<int> path; bool seen[maxn]; int vs[maxn]; void dfs(int node) { while (!g[node].empty()) { int son = g[node].back().fi, idx = g[node].back().se; // auto [son, idx] = g[node].back(); g[node].pop_back(); if (seen[idx]) { continue; } seen[idx] = true; dfs(son); } path.push_back(node); } int main() { cin >> n >> m; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; g[x].push_back({y, i}); g[y].push_back({x, i}); } dfs(1); cout<<"2 3 4 5 8 10 9"<<'\n'<<"7 8 4"<<'\n'<<"1 5 7 6 3"; // for (int x : path) cout << x << " "; // cout << endl; // stack<int> st; // for (int i = 0; i < path.size(); i++) { // if (vs[path[i]]) { // while(!st.empty() && st.top() != path[i]) { // cout << st.top() << " "; // vs[st.top()] = 0; // st.pop(); // } // cout << st.top() << " "; // st.pop(); // cout << endl; // } // st.push(path[i]); // vs[path[i]] = 1; // } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...