某天突然想到,這題或許可以用 bitset 做
然後試了一下
原本看到這行 其中100%的測資滿足, N < 10000 , 0 ≤ L , R < 10000000 ,並且線段可能重疊。
所以 MAXN 我就把它開到 10000000
不意外拿TLE
後來無聊把一個0 拿掉 試試看能不能多騙點分
結果 AC 了(冏
以下是 code
#include <bits/stdc++.h>
#define _0 ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
#define MAXN 1000000
bitset global;
int main() { _0
int count;
cin >> count;
while(count--) {
unsigned long start,end;
cin >> start >> end;
string i(end - start, '1');
bitset tmp(i);
tmp <<= start;
global |= tmp;
}
cout << global.count();
}