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;
vector<pair<int, int> > seg;
// vector<int> us(n + 1, 0);
int lst = 0, id = 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);
++id;
seg.push_back({l, r});
}else if(ty == 2) {
cin>>x;
seg[x - 1] = {0, 0};
}else {
cin>>l>>r>>x;
l = (l ^ (t * lst)), r = (r ^ (t * lst));
if(l > r)swap(l, r);
int res = 0;
for(int i = 0; i < id; i++) {
int lx = max(l, seg[i].fi), rx = min(r, seg[i].se);
if((rx - lx + 1) >= x)res ++;
}
cout << res << '\n';
lst = res;
}
}
}
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... |