Pagini recente » Cod sursa (job #424366) | Cod sursa (job #1186489) | Cod sursa (job #2491831) | Profil Sasha_12454 | Cod sursa (job #2753448)
#include <bits/stdc++.h>
#define nozerous(x) (x & -x)
#define MOD 9901
#define EPS 0.00001
using namespace std;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = (1 << 30), NMAX(1000005), VMAX(1000000);
using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using Point = array<int, 2>;
using ll = long long;
using cd = complex<double>;
const double PI = acos(-1);
void BUNA(const string& task = "")
{
if (!task.empty())
freopen((task + ".in").c_str(), "r", stdin),
freopen((task + ".out").c_str(), "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void PA()
{
exit(0);
}
int n, s, v[NMAX], m;
bool viz[NMAX];
vector<int> G[NMAX];
vector<pair<int, int> > sol;
void DFS(int nod){
viz[nod] = 1;
for(auto it: G[nod])
if(!viz[it]){
sol.push_back({nod, it});
DFS(it);
}
}
int main()
{
BUNA();
cin >> n >> m;
for(int i = 1; i <= m; ++i){
int x, y;
cin >> x >> y;
G[x].push_back(y);
G[y].push_back(x);
}
DFS(1);
for(int i = 1; i <= n; ++i)
if(!viz[i]){
cout << -1;
return 0;
}
cout << 2 * n - 2 << '\n';
for(int i = sol.size() - 1; i >= 0; --i)
cout << sol[i].second << ' ' << sol[i].first << '\n';
for(auto it: sol)
cout << it.first << ' ' << it.second << '\n';
PA();
}