Special_Tony @ 2024-03-03 21:17:37
rt,WA#12345,hackAC,Code:
# include <bits/stdc++.h>
# define ffor(i,name) \
for (auto i = name.begin (); i != name.end (); ++ i)
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int n, m, a[1005], b[1005], sum;
bitset <40000005> tr, lazy;
void pushdown (int& x, int& l, int& r) {
if (lazy[x]) {
lazy[l] = lazy[r] = 1;
tr[l] = tr[r] = 1;
lazy[x] = 0;
}
return ;
}
void upd (int x, int l, int r, int L, int R) {
if (l == L && r == R) {
tr[x] = lazy[x] = 1;
return ;
}
int mid = l + r >> 1, left = x << 1, right = left | 1;
pushdown (x, left, right);
if (R <= mid)
upd (left, l, mid, L, R);
else if (L > mid)
upd (right, mid + 1, r, L, R);
else
upd (left, l, mid, L, mid), upd (right, mid + 1, r, mid + 1, R);
return ;
}
bool find (int x, int l, int r, int L, int R) {
if (l == L && r == R)
return tr[x];
int mid = l + r >> 1, left = x << 1, right = left | 1;
pushdown (x, left, right);
if (R <= mid)
return find (left, l, mid, L, R);
if (L > mid)
return find (right, mid + 1, r, L, R);
return find (left, l, mid, L, mid) && find (right, mid + 1, r, mid + 1, R);
}
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> n >> m;
for (int i = 0; i < m; ++ i)
cin >> a[i] >> b[i];
while (m --)
sum += ! find (1, 1, n, a[m], b[m]), upd (1, 1, n, a[m], b[m]);
cout << sum;
return 0;
}
by Special_Tony @ 2024-03-03 21:29:12
和@rliumin 错的一模一样,错误信息也一样
by Special_Tony @ 2024-03-03 21:30:04
哦wssb忘了pushup了