#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
#define int ll
const int mxn = 5050;
int Q,t;
set<int> id;
pii arr[mxn];
int preans = 0;
main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>Q>>t;
for(int i = 1;i<=Q+1;i++)id.insert(i);
while(Q--){
int tp;
cin>>tp;
if(tp == 1){
int l,r;
cin>>l>>r;
l = l^(t*preans);
r = r^(t*preans);
arr[*id.begin()] = {l,r};
id.erase(*id.begin());
}
else if(tp == 2){
int tar;
cin>>tar;
id.insert(tar);
arr[tar] = {-1,-1};
}
else{
int l,r,v;
cin>>l>>r>>v;
l = l^(t*preans);
r = r^(t*preans);
if(r<l)swap(l,r);
int tans = 0;
for(int i = 1;i<=*id.rbegin();i++){
pii range = {max(arr[i].fs,l),min(arr[i].sc,r)};
if(range.sc-range.fs+1>=v)tans++;
}
cout<<(preans = tans)<<'\n';
}
}
return 0;
}
/*
6 0
1 3 10
1 3 5
3 6 10 6
2 1
1 3 10
3 6 4 2
*/
Compilation message
segments.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
18 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
15 ms |
700 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
19 ms |
10064 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
19 ms |
10072 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
18 ms |
10072 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
15 ms |
700 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
15 ms |
700 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |