이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define pb push_back
/*
dont get stuck on one approach
write stuff on paper
edge cases(n=1?)
look for : dp,bs,bf,observations...
implement and debug smarter
*/
void solve(){
int n,t;
cin >> n >> t;
set<int> s;
for(int i=1;i<n+5;i++) s.insert(i);
multiset<array<int,2>> ms;
array<int,2> ar[n+5];
int last=0;
while(n--){
int op;
cin >> op;
if(op==1){
int a,b;
cin >> a >> b;
a = a ^ (t*last);
b = b ^ (t*last);
if(a>b) swap(a,b);
int id = *s.begin();
ar[id]={a,b};
s.erase(id);
ms.insert({a,b});
}
else if(op==2){
int id;
cin >> id;
ms.erase(ms.find(ar[id]));
s.insert(id);
}
else{
int a,b,k;
cin >> a >> b >> k;
a = a ^ (t*last);
b = b ^ (t*last);
if(a>b) swap(a,b);
int ans=0;
for(array<int,2> x : ms){
int l = max(x[0],a);
int r = min(x[1],b);
if(r-l+1>=k) ans++;
}
last=ans;
cout << ans << endl;
}
}
}
int32_t main(){
cin.tie(0);
ios::sync_with_stdio(0);
int t=1;//cin >> t;
while(t--) solve();
}
# | 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... |