#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tpl;
#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())
int intr (pii a, pii b) {
return min(a.second, b.second) - max(a.first, b.first) + 1;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, t, ans = 0; cin >> n >> t;
vector<bool> used(n);
vector<pii> seg(n);
for (int i = 0; i < n; i++) {
int type; cin >> type;
if (type == 1) {
int a, b, id = 0; cin >> a >> b;
int l = (a ^ (t * ans)), r = (b ^ (t * ans));
if (l > r) swap(l, r);
for (; used[id]; id++);
used[id] = 1, seg[id] = {l, r};
}
else if (type == 2) {
int id; cin >> id;
used[id - 1] = 0;
}
else {
int a, b, k; cin >> a >> b >> k;
int l = (a ^ (t * ans)), r = (b ^ (t * ans));
if (l > r) swap(l, r);
ans = 0;
// for (int j = 0; j < n; j++)
// if (used[j]) cout << "(" << seg[j].first << " " << seg[j].second << ") ";
// cout << "\n";
for (int j = 0; j < n; j++)
if (used[j] && intr(seg[j], make_pair(l, r)) >= k) ans++;
cout << ans << "\n";
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |