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>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
//#define int long long
#define pii pair < int, int >
using namespace std;
const int M = 4e5 + 5;
//const int mod = 1e9 + 7;
int n, t;
main() {
//file("pieaters");
/*ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
cin >> n >> t;
int id = 0, last = 0, cs = 0;
multiset < pair < int, pii > > st;
while(n--) {
int tp, a, b, k;
cin >> tp;
if(tp == 1) {
cin >> a >> b;
a ^= (t * last);
b ^= (t * last);
if(a > b) swap(a, b);
st.insert({++id, {a, b}});
} else if(tp == 2) {
cin >> k;
st.erase(*st.lower_bound({k, {0, 0}}));
} else {
cin >> a >> b >> k;
a = a ^ (last * t);
b = b ^ (last * t);
if(a > b) swap(a, b);
int ans = 0;
//cout << "Case " << ++cs << ": " << a << " " << b << endl;
for(multiset < pair < int, pii > >::iterator it = st.begin(); it != st.end(); it++) {
pii z = (*it).second;
//cout << z.first << " " << z.second << endl;
if(min(z.second, b) - max(z.first, a) + 1 >= k) {
ans++;
}
}
cout << ans << endl;
last = ans;
}
}
}
Compilation message (stderr)
segments.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main() {
| ^~~~
segments.cpp: In function 'int main()':
segments.cpp:23:27: warning: unused variable 'cs' [-Wunused-variable]
23 | int id = 0, last = 0, cs = 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... |