This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |