#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int M, C = 0;
cin >> M;
vector<bool> vec(1000010, 0);
while (M--) {
int D, X, Y;
cin >> D >> X >> Y;
int L = X + C, R = Y + C;
if (L > R) swap(L, R);
if (R >= 1000010) R = 1000009;
if (D == 1) {
int cnt = 0;
for (int i = L; i <= R; ++i) cnt += vec[i];
C = cnt;
cout << C << '\n';
} else {
for (int i = L; i <= R; ++i) vec[i] = 1;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |