This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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>
const int mxn = 5050;
int Q,t;
int idx = 0;
pii arr[mxn];
int preans = 0;
main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>Q>>t;
while(Q--){
int tp;
cin>>tp;
if(tp == 1){
int l,r;
cin>>l>>r;
l = l^(t*preans);
r = r^(t*preans);
arr[++idx] = {l,r};
}
else if(tp == 2){
int tar;
cin>>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<=idx;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 (stderr)
segments.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main(){
| ^~~~
# | 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... |