-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcf22d.cpp
More file actions
43 lines (38 loc) · 757 Bytes
/
cf22d.cpp
File metadata and controls
43 lines (38 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX_N = 1007;
struct P {
int s, t;
bool operator < (const P &rhs) const {
return t < rhs.t;
}
};
int n, ans[MAX_N];
P p[MAX_N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", &p[i].s, &p[i].t);
if (p[i].s > p[i].t) swap(p[i].s, p[i].t);
}
sort(p + 1, p + 1 + n);
int Max = - (int) 1e9 + 7, cnt = 0;
for (int i = 1; i <= n; ++i) {
printf("%d %d\n", p[i].s, p[i].t);
}
for (int i = 1; i <= n; ++i) {
if (p[i].s > Max) {
Max = p[i].t;
ans[cnt++] = p[i].t;
}
}
printf("%d\n", cnt);
for (int i = 0; i < cnt; ++i) {
if (i == 0) printf("%d", ans[i]);
else printf(" %d", ans[i]);
}
puts("");
return 0;
}