Submission #984842

#TimeUsernameProblemLanguageResultExecution timeMemory
984842boris_mihovNewspapers (CEOI21_newspapers)C++17
4 / 100
3 ms7772 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> #include <queue> typedef long long llong; const int MAXN = 300000 + 10; const int INF = 1e9; int n, m; std::vector <int> order; std::vector <int> g[MAXN]; void dfs(int node, int par) { order.push_back(node); for (const int &u : g[node]) { if (u == par) { continue; } dfs(u, node); order.push_back(node); } } void solve() { dfs(1, 0); std::cout << "YES\n"; std::cout << order.size() << '\n'; for (const int &u : order) { std::cout << u << ' '; } std::cout << '\n'; } void input() { std::cin >> n >> m; if (m >= n) { std::cout << "NO\n"; exit(0); } for (int i = 1 ; i <= m ; ++i) { int u, v; std::cin >> u >> v; g[u].push_back(v); g[v].push_back(u); } } void fastIOI() { std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int main() { fastIOI(); input(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...