#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
#define vel vector<long long>
#define V vector
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int pr = 1000000007;
int ref(int &a) {
a = a % pr;
a += pr;
a = a % pr;
return a;
}
void uni(vel &a) {
vel ans(1, a[0]);
rep(i, a.size() - 1) { if (a[i + 1] != a[i]) { ans.push_back(a[i + 1]); } }
a = ans;
}
int rui(int a, int n) {
if (n == 0) { return 1; }
int back = rui(a, n / 2);
back *= back; ref(back);
if (n % 2 == 0) { return back; }
return (back*a) % pr;
}
int inv(int a) {
return rui(a, pr - 2);
}
int main() {
int n; cin >> n;
vel a(n);
vel b(n);
vel all_time(1, 0);
rep(i, n) {
cin >> a[i] >> b[i]; b[i]++;
all_time.push_back(a[i]);
all_time.push_back(b[i]);
}
sort(all_time.begin(), all_time.end());
uni(all_time);
int sz = all_time.size();
vel gap(sz - 1);
rep(i, sz - 1) { gap[i] = all_time[i + 1] - all_time[i]; }
vel count(sz);
rep(i, n) {
a[i] = lower_bound(all_time.begin(), all_time.end(), a[i])-all_time.begin();
b[i] = lower_bound(all_time.begin(), all_time.end(), b[i])-all_time.begin();
rep(j, b[i] - a[i]) {
count[a[i] + j]++;
}
}
V<vel> com(sz);
rep(i, sz) {
com[i].push_back(1);
int ba = 1;
rep(j, count[i]) {
ba *= gap[i] - j; ref(ba);
ba *= inv(j+1);
com[i].push_back(i);
}
}
V<vel> dp0(n,vel(sz, 0));
V<V<vel>> dp1(n, V<vel>(sz));
rep(i, n) {
rep(j, sz) {
dp1[i][j] = vel(count[j] + 1, 0);
}
}
}
Compilation message
boat.cpp: In function 'void uni(std::vector<long long int>&)':
boat.cpp:9:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define rep(i,n) for(int i=0;i<n;i++)
boat.cpp:19:6:
rep(i, a.size() - 1) { if (a[i + 1] != a[i]) { ans.push_back(a[i + 1]); } }
~~~~~~~~~~~~~~~
boat.cpp:19:2: note: in expansion of macro 'rep'
rep(i, a.size() - 1) { if (a[i + 1] != a[i]) { ans.push_back(a[i + 1]); } }
^~~
boat.cpp: At global scope:
boat.cpp:32:10: error: '::main' must return 'int'
int main() {
^