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>
#pragma optimize("g", on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
void Freopen () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
using namespace std;
#define fi first
#define se second
#define int long long
const int N = 2e3 + 7;
void solve() {
int n, t;
cin>>n>>t;
if(n <= 5000) {
vector<pair<int, int> > seg(n + 1, {0, 0});
set<int> id;
for(int i = 1; i <= n; i++)id.insert(i);
int lst = 0;
for(int _i = 0; _i < n; _i++) {
int ty, l, r, x;
cin>>ty;
if(ty == 1) {
cin>>l>>r;
l = (l ^ (t * lst)), r = (r ^ (t * lst));
if(l > r)swap(l, r);
int dd = *id.begin();
id.erase(dd);
seg[dd] = {l, r};
}else if(ty == 2) {
cin>>x;
seg[x] = {0, 0};
id.insert(x);
}else {
cin>>l>>r>>x;
l = (l ^ (t * lst)), r = (r ^ (t * lst));
if(l > r)swap(l, r);
int res = 0;
// cout << "\n>>>>>>>\n" << l << ' ' << r << '\n';
for(int i = 1; i <= n; i++) {
int lx = max(l, seg[i].fi), rx = min(r, seg[i].se);
// cout << lx << ' ' << rx << '\n';
if((rx - lx + 1) >= x)res ++;
}
// cout << '\n';
cout << res << '\n';
lst = res;
}
}
return;
}
if(t == 0) {
}else {
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
Freopen();
int T = 1;
// cin>>T;
while(T --)solve();
}
/*
*/
Compilation message (stderr)
segments.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
2 | #pragma optimize("g", on)
|
segments.cpp: In function 'void Freopen()':
segments.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | freopen("input.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
segments.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |