#include <bits/stdc++.h>
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define x first
#define y second
#define int long long
#define nl "\n"
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;
const int N = (int)5e4 + 7;
const int M = (int)7e6 + 7;
const ll MOD = (ll)1e9 + 7;
const int inf = (int)1e9 + 7;
const ll INF = (ll)3e18 + 7;
pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}};
int n, t;
pii p[5001];
void solve() {
cin >> n >> t;
for(int i = 1; i <= n; ++i) p[i] = {-1, -1};
multiset<pair<pii, int> > s;
int ans = 0;
while(n--) {
char tp;
cin >> tp;
int l, r, k;
if(tp == '1') {
cin >> l >> r;
l = (l ^ (t * ans)), r = (r ^ (t * ans));
if(l > r) swap(l, r);
int id = 0;
for(int i = 1; i <= 5000; ++i) {
if(p[i].x == -1) {
id = i;
break;
}
}
p[id] = {l, r};
s.insert({{l, r}, id});
}
else if(tp == '2') {
int id;
cin >> id;
s.erase({{p[id].x, p[id].y}, id});
} else {
cin >> l >> r >> k;
l = (l ^ (t * ans)), r = (r ^ (t * ans));
if(l > r) swap(l, r);
int cnt = 0;
for(auto e : s) {
int x = e.x.x, y = e.x.y;
int cur = 0;
cur = max(0ll, min(y, r) - max(l, x) + 1);
if(cur >= k) cnt++;
}
ans = cnt;
cout << ans << nl;
}
}
}
signed main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int test = 1;
//cin >> test;
for(int i = 1; i <= test; ++i) {
//cout << "Case " << i << ": ";
solve();
}
return 0;
}
/*
6 1
1 1 2
3 2 4 2
1 3 5
3 2 3 1
2 1
3 0 3 1
6 0
1 3 10
1 3 5
3 6 10 6
2 1
1 3 10
3 6 4 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
45 ms |
716 KB |
Output is correct |
6 |
Correct |
63 ms |
736 KB |
Output is correct |
7 |
Correct |
10 ms |
460 KB |
Output is correct |
8 |
Correct |
28 ms |
584 KB |
Output is correct |
9 |
Correct |
25 ms |
660 KB |
Output is correct |
10 |
Correct |
17 ms |
716 KB |
Output is correct |
11 |
Correct |
63 ms |
684 KB |
Output is correct |
12 |
Correct |
78 ms |
684 KB |
Output is correct |
13 |
Correct |
19 ms |
656 KB |
Output is correct |
14 |
Correct |
27 ms |
708 KB |
Output is correct |
15 |
Correct |
3 ms |
460 KB |
Output is correct |
16 |
Correct |
3 ms |
500 KB |
Output is correct |
17 |
Correct |
19 ms |
580 KB |
Output is correct |
18 |
Correct |
20 ms |
716 KB |
Output is correct |
19 |
Correct |
19 ms |
580 KB |
Output is correct |
20 |
Correct |
25 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
588 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
588 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
588 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
45 ms |
716 KB |
Output is correct |
6 |
Correct |
63 ms |
736 KB |
Output is correct |
7 |
Correct |
10 ms |
460 KB |
Output is correct |
8 |
Correct |
28 ms |
584 KB |
Output is correct |
9 |
Correct |
25 ms |
660 KB |
Output is correct |
10 |
Correct |
17 ms |
716 KB |
Output is correct |
11 |
Correct |
63 ms |
684 KB |
Output is correct |
12 |
Correct |
78 ms |
684 KB |
Output is correct |
13 |
Correct |
19 ms |
656 KB |
Output is correct |
14 |
Correct |
27 ms |
708 KB |
Output is correct |
15 |
Correct |
3 ms |
460 KB |
Output is correct |
16 |
Correct |
3 ms |
500 KB |
Output is correct |
17 |
Correct |
19 ms |
580 KB |
Output is correct |
18 |
Correct |
20 ms |
716 KB |
Output is correct |
19 |
Correct |
19 ms |
580 KB |
Output is correct |
20 |
Correct |
25 ms |
576 KB |
Output is correct |
21 |
Runtime error |
1 ms |
588 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
45 ms |
716 KB |
Output is correct |
6 |
Correct |
63 ms |
736 KB |
Output is correct |
7 |
Correct |
10 ms |
460 KB |
Output is correct |
8 |
Correct |
28 ms |
584 KB |
Output is correct |
9 |
Correct |
25 ms |
660 KB |
Output is correct |
10 |
Correct |
17 ms |
716 KB |
Output is correct |
11 |
Correct |
63 ms |
684 KB |
Output is correct |
12 |
Correct |
78 ms |
684 KB |
Output is correct |
13 |
Correct |
19 ms |
656 KB |
Output is correct |
14 |
Correct |
27 ms |
708 KB |
Output is correct |
15 |
Correct |
3 ms |
460 KB |
Output is correct |
16 |
Correct |
3 ms |
500 KB |
Output is correct |
17 |
Correct |
19 ms |
580 KB |
Output is correct |
18 |
Correct |
20 ms |
716 KB |
Output is correct |
19 |
Correct |
19 ms |
580 KB |
Output is correct |
20 |
Correct |
25 ms |
576 KB |
Output is correct |
21 |
Runtime error |
1 ms |
588 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |