forked from Anmol2307/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACTIV.cpp
135 lines (108 loc) · 2.37 KB
/
ACTIV.cpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#pragma comment(linker, "/STACK:60777216")
#define printTime(begin, end) printf("%.3lf\n", (double)(end - begin) / (double)CLOCKS_PER_SEC)
#include <string.h>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <complex>
#include <iostream>
#include <fstream>
#include <sstream>
#include <bitset>
#include <limits>
#include <ctime>
#include <cassert>
#include <valarray>
using namespace std;
#define IN(a) freopen(a, "r", stdin)
#define OUT(a) freopen(a, "w", stdout)
#define mp(a, b) make_pair(a, b)
#define det(a, b, c, d) (a * d - c * b)
#define sbstr(s, i, j) s.substr(i, j - i + 1)
#define clear(dp) memset(dp, -1, sizeof(dp))
#define reset(arr) memset(arr, 0, sizeof(arr))
#define EPS 1e-9
#define PI acos(-1.0)
#define MOD 100000000
#define IINF 1000000000
#define LINF 6000000000000000000LL
#define my_max(a, b) (a > b ? a : b)
#define my_min(a, b) (a < b ? a : b)
struct Activity {
int s_;
int e_;
Activity (int s = 0, int e = 0) :
s_(s),
e_(e) {
}
};
bool operator < (const Activity &op1, const Activity &op2) {
if(op1.e_ < op2.e_)
return true;
if(op1.e_ > op2.e_)
return false;
return op1.s_ < op2.s_;
}
ostream& operator << (ostream &os, Activity &op) {
os << "{\n" << "start = " << op.s_ << "\n";
os << "finish = " << op.e_ << "\n}";
return os;
}
const int maxN = 100007;
int n;
int f[maxN][3];
Activity a[maxN];
int lower_bound (int val) {
int res = -1;
int lo = 0, hi = n - 1;
while(lo <= hi) {
int mid = (lo + hi) >> 1;
if(a[mid].s_ >= val) {
res = mid;
hi = mid - 1;
}
else {
lo = mid + 1;
}
}
return res;
}
int go (int pos) {
int &ref = f[pos];
if(ref != -1)
return ref;
}
void init () {
scanf("%d", &n);
if(n == -1) exit(0);
for(int i = 0; i < n; ++i)
scanf("%d%d", &a[i].s_, &a[i].e_);
sort(a, a + n);
memset(f, -1, sizeof(f));
}
void solve () {
int ans = go(0);
ans += n;
if(ans >= MOD)
ans -= MOD;
printf("%.8d\n", ans);
}
int main () {
int test_case;
while(true) {
init();
solve();
}
return 0;
}