This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("unroll-loops")
#pragma gcc optimize("Ofast")
#pragma GCC optimization("Ofast")
#pragma optimize(Ofast)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define str string
#define fastio ios::sync_with_stdio(0), cin.tie(0);
#define fs first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define len(x) x.size()
#define print(a) \
for (auto &x : a) \
cout << x << " "; \
cout << endl;
#define printmp(a) \
for (auto &x : a) \
cout << x.fs << " " << x.ss.fs << ' ' << x.ss.ss << endl;
const int mod = 998244353;
void solve(){
int n, t;
cin >> n >> t;
map<int, pair<int, int>> mp;
set<int> free;
for(int i = 0; i < n; i ++)
free.insert(i + 1);
int lastans = 0;
for(int i = 0; i < n; i ++){
int type;
cin >> type;
if(type == 1){
int l, r;
cin >> l >> r;
l = l ^ (t * lastans);
r = r ^ (t * lastans);
if(l > r)
swap(l, r);
mp[*free.begin()] = {l, r};
free.erase(free.begin());
}
else if(type == 2){
int x;
cin >> x;
mp.erase(x);
free.insert(x);
}
else{
int l, r, k;
cin >> l >> r >> k;
l = l ^ (t * lastans);
r = r ^ (t * lastans);
if(l > r)
swap(l, r);
int ans = 0;
for(auto x : mp){
pair<int, int> y = x.ss;
int pl = max(l, y.fs), pr = min(r, y.ss);
if(pr - pl > k)
ans ++;
}
cout << ans << endl;
lastans = ans;
}
}
}
signed main()
{
fastio int t = 1;
// cin >> t;
while (t--)
{
solve();
cout << endl;
}
}
Compilation message (stderr)
segments.cpp:2: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
2 | #pragma gcc optimize("Ofast")
|
segments.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
3 | #pragma GCC optimization("Ofast")
|
segments.cpp:4: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
4 | #pragma optimize(Ofast)
|
# | 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... |