#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 3e4 + 100;
#define int long long
set<pair<int,int>> st;
void add_seg(int l, int r) {
if (st.size()) {
auto x = st.lower_bound(make_pair(l, 0));
if (x != st.begin()) {
x--;
if ((*x).s >= l) {
l = min(l, (*x).f);
st.erase(x);
}
}
x = st.upper_bound(make_pair(r, 0));t
x--;
if (x != st.begin() && (*x).f <= r) {
r = max(r, (*x).s);
st.erase(x);
}
}
st.insert({l, r});
}
signed main() {
fast
ll n, A, B;
cin >> n >> A >> B;
if (1e9 * 1LL * 1e9 / A <= B) {
int ans = 0;
for (int i = 0; i < n; i++) {
int l, r;
cin >> l >> r;
add_seg(l, r);
}
for (auto u : st)
ans += u.s - u.f + 1;
cout << ans << "\n";
return 0;
}
A *= B;
for (int i = 0; i < n; i++) {
int l, r;
cin >> l >> r;
int x = l % A;
int y = r % A;
if (y < x || r - l + 1 >= A) {
add_seg(x, A-1);
add_seg(0, y);
} else
add_seg(x, y);
}
ll ans = 0;
for (auto u : st)
ans += u.s - u.f + 1;
cout << ans << "\n";
}
Compilation message
strange_device.cpp: In function 'void add_seg(long long int, long long int)':
strange_device.cpp:24:45: error: 't' was not declared in this scope
24 | x = st.upper_bound(make_pair(r, 0));t
| ^