link: http://codeforces.com/contest/330/problem/B
I think the problem is hard at first. However, when you think deep in it you will find it is so easy.
/*
ID: zypz4571
LANG: C++
TASK: 192b.cpp
*/ #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime> #define INF 0x3f3f3f3f
#define REP(i, n) for(int i=0;i<int(n);++i)
#define FOR(i, a, b) for(int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for(int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for(int i=1;i<=int(n);++i)
#define mid int m=(l+r)/2
using namespace std;
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
int n, m; cin >> n >> m;
multiset<int> rp;
int a, b;
REP (i, m) {
cin >> a >> b;
rp.insert(a); rp.insert(b);
}
int tmp;
FOR(i, , n+) {
if (rp.count(i) == ) {
tmp = i; break;
}
}
cout <<n-<<endl;
FOR (i, , n+) {
if (i != tmp) {
cout << min(tmp, i) <<' '<<max(tmp,i)<<endl;
}
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
It seems that I can not use STL very skillfully.