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 <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
using namespace std;
const long long oo = 1000000000000000000;
long long int sum, ans = 0, mx = 0, mn = 1000000000, num, pos;
/*
ViHHiPuh
(( `'-""``""-'` ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ `;#'#'# - #'#'#;` \
\_)) -----'#'----- ((_/
# --------- #
'# ------- ------ #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
cout << fixed << setprecision(6) << x;
freopen ( "sum.in", "r", stdin )
*/
set <pair<int, pair<int, int> > > st;
multiset <pair<int, int> > s;
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, m, t, l, r, x, ll, rr;
cin >> n >> m;
ans = 0;
for ( int query = 1; query <= n; query ++ ) {
cin >> t >> l;
if ( t == 1 ) {
cin >> r;
l = ( l ^ ( m * ans ) );
r = ( r ^ ( m * ans ) );
if ( l > r )
swap( l, r );
num ++;
if ( n <= 5000 )
st.insert( { num, make_pair( l, r ) } );
else
s.insert( { l, r } );
}
else if ( t == 2 ) {
st.erase( st.lower_bound( { l, make_pair( 0, 0 ) } ) );
}
else {
cin >> r >> x;
l = ( l ^ ( m * ans ) );
r = ( r ^ ( m * ans ) );
if ( l > r )
swap( l, r );
if ( r - l + 1 < x ) {
cout << 0 << "\n";
continue;
}
ans = 0;
if ( n <= 5000 ) {
for ( auto i : st ) {
if ( i.second.second >= l && i.second.first <= r ) {
ll = max( i.second.first, l );
rr = min( i.second.second, r );
if ( rr - ll + 1 >= x )
ans ++;
}
}
}
else {
auto it = s.lower_bound( { l - ( num ), 0 } );
while ( it != s.end() && ( r - it->first + 1 ) >= x ) {
ll = max( it->first, l );
rr = min( it->second, r );
if ( rr - ll + 1 >= x )
ans ++;
it = ++it;
}
}
cout << ans << "\n";
}
}
}
/*
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 |
---|
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... |