-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18781.cpp
More file actions
51 lines (44 loc) · 849 Bytes
/
18781.cpp
File metadata and controls
51 lines (44 loc) · 849 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
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
using namespace std;
const ll INF = 1e9 + 7;
const ll DIV = (ll)1e9 +7;
ll Pow(ll a, ll r){
ll ret = 1;
while(r){
if(r&1){
ret = ret * a % DIV;
}
a = a * a % DIV;
r >>= 1;
}
return ret;
}
int n;
int arr[202020];
int ok[202020];
int main()
{
fastio;
cin >> n;
for(int i = 0;i< n;i++){
int a, b;
cin >> a>> b;
arr[a]++;
arr[b]--;
ok[a]++;
}
for(int i = 1;i <= 2*n;i++){
arr[i] += arr[i - 1];
}
ll ans = 0;
for(int i = 1;i<=2*n;i++){
if(ok[i]){
ans += Pow(2, n - 1 - arr[i - 1]) ;
ans %= DIV;
}
}
cout << (ans + DIV)%DIV;
return 0;
}