#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;
while ( n -- ) {
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 )
continue;
num = x - ( r - l + 1 );
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";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
3744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5079 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5047 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |