codeforces 192b

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.

 1 /*
 2 ID: zypz4571
 3 LANG: C++
 4 TASK: 192b.cpp
 5  */
 6 
 7 #include <iostream>
 8 #include <cstdio>
 9 #include <cstdlib>
10 #include <cstring>
11 #include <cmath>
12 #include <cctype>
13 #include <algorithm>
14 #include <queue>
15 #include <deque>
16 #include <queue>
17 #include <list>
18 #include <map>
19 #include <set>
20 #include <vector>
21 #include <utility>
22 #include <functional>
23 #include <fstream>
24 #include <iomanip>
25 #include <sstream>
26 #include <numeric>
27 #include <cassert>
28 #include <ctime>
29 
30 #define INF 0x3f3f3f3f
31 #define REP(i, n) for(int i=0;i<int(n);++i)
32 #define FOR(i, a, b) for(int i=int(a);i<int(b);++i)
33 #define DWN(i, b, a) for(int i=int(b-1);i>=int(a);--i)
34 #define REP_1(i, n) for(int i=1;i<=int(n);++i)
35 #define mid int m=(l+r)/2
36 using namespace std;
37 int main ( int argc, char *argv[] )
38 {
39 #ifndef ONLINE_JUDGE
40 freopen("in.txt", "r", stdin);
41 #endif
42     int n, m; cin >> n >> m;
43     multiset<int> rp;
44     int a, b;
45     REP (i, m) {
46         cin >> a >> b;
47         rp.insert(a); rp.insert(b);
48     }
49     int tmp;
50     FOR(i, 1, n+1) {
51         if (rp.count(i) == 0) {
52             tmp = i; break;
53         }
54     }
55     cout <<n-1<<endl;
56     FOR (i, 1, n+1) {
57         if (i != tmp) {
58             cout << min(tmp, i) <<' '<<max(tmp,i)<<endl;
59         }
60     }
61         return EXIT_SUCCESS;
62 }                /* ----------  end of function main  ---------- */

It seems that I can not use STL very skillfully.

posted on 2013-07-22 03:07  aries__liu  阅读(333)  评论(2编辑  收藏  举报