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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
#define conts continue
#define ceil2(x,y) ((x+y-1)/(y))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rev(i,s,e) for(int i = s; i >= e; --i)
#define trav(i,a) for(auto &i : a)
template<typename T>
void amin(T &a, T b) {
a = min(a,b);
}
template<typename T>
void amax(T &a, T b) {
a = max(a,b);
}
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
/*
refs:
other solutions
*/
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = int(1e9) + 5;
const ll inf2 = ll(1e18) + 5;
struct DS{
vector<pii> a;
void insert(int l, int r){
a.pb({l,r});
}
int query(int l1, int r1, int k){
if(r1-l1 < k) return 0;
int ans = 0;
for(auto [l2,r2] : a){
if(r2-l2 < k) conts;
ans++;
if(r2 < l1+k) ans--;
if(l2 > r1-k) ans--;
}
return ans;
}
};
void solve(int test_case)
{
int q,c; cin >> q >> c;
DS ds1,ds2;
vector<pii> a;
a.pb({0,0});
int last_ans = 0;
while(q--){
int t; cin >> t;
if(t == 1){
int l,r; cin >> l >> r;
l ^= c*last_ans, r ^= c*last_ans;
if(l > r) swap(l,r);
ds1.insert(l,r);
a.pb({l,r});
}
else if(t == 2){
int id; cin >> id;
auto [l,r] = a[id];
ds2.insert(l,r);
}
else{
int l,r,k; cin >> l >> r >> k;
l ^= c*last_ans, r ^= c*last_ans;
if(l > r) swap(l,r);
k--;
int ans = ds1.query(l,r,k)-ds2.query(l,r,k);
cout << ans << endl;
last_ans = ans;
}
}
}
int main()
{
fastio;
int t = 1;
// cin >> t;
rep1(i, t) {
solve(i);
}
return 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... |