이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define nl '\n'
const int N = 2e5 + 1;
int q, t, lans = 0;
multiset< pair<int, int> >s;
map<int, pair<int, int>>mp;
set< int >st;
signed main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >>q >>t;
for( int i = 1; i <= q; ++i )
st.insert( i );
while( q-- )
{
int type, l, r, k, id;
cin >>type;
if( type == 1 )
{
cin >>l >>r;
l = (l ^ (t * lans));
r = (r ^ (t * lans));
if( l > r )
swap(l, r);
s.insert({l, r});
id = *st.begin();
st.erase( id );
mp[id] = {l, r};
}
else if( type == 2 )
{
cin >>id;
l = mp[id].F;
r = mp[id].S;
s.erase({l, r});
st.insert( id );
}
else
{
cin >>l >>r >>k;
l = (l ^ (t * lans));
r = (r ^ (t * lans));
if( l > r )
swap(l, r);
int res = 0;
for( auto [l1, r1]: s )
{
if( l1 > r || l > r1 )
continue;
int l2 = max(l, l1);
int r2 = min(r, r1);
res += (r2 - l2 + 1 >= k);
}
cout <<res <<nl;
lans = res;
}
}
}
# | 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... |