forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1076Gene Assembly.cpp
More file actions
57 lines (52 loc) · 856 Bytes
/
1076Gene Assembly.cpp
File metadata and controls
57 lines (52 loc) · 856 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
zju 1076 Gene Assembly
00:00.00 448k
2004.08.17 by adai
*/
#include <iostream>
#include <string>
using namespace std;
#ifdef WIN32
#define for if(0); else for
#endif
class exon {
public:
int start;
int end;
int index;
}a[1000];
int cmp(const void *t1, const void *t2) {
exon *a, *b;
a = (exon *)t1;
b = (exon *)t2;
return (*a).end - (*b).end;
}
int main () {
int n;
while (cin >> n && n != 0) {
for (int i = 0; i < n; i ++) {
cin >> a[i].start >> a[i].end;
a[i].index = i + 1;
}
qsort(a, n, sizeof(exon), cmp);
int first = 1;
int bound = 0;
int tt = 0;
while (1) {
for (; tt < n; tt ++) {
if (a[tt].start > bound) {
if (!first) cout << " ";
else first = 0;
cout << a[tt].index;
bound = a[tt].end;
break;
}
}
if (tt == n) {
cout << endl;
break;
}
}
}
return 0;
}