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("Ofast,O2,O3,unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << "[" << H << "]";
debug_out(T...);
}
#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define SZ(s) ((int)s.size())
#define all(x) (x).begin(), (x).end()
#define lla(x) (x).rbegin(), (x).rend()
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define MP make_pair
clock_t startTime;
int getCurrentTime() {
return int((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000);
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 2e6 + 3e2;
const int M = 5555;
void solve(int TC){
int n, t;
cin >> n >> t;
set<pair<int, int>> seg;
vector<pair<int, int>> vec_seg;
int lastans = 0;
while (n--){
int op;
cin >> op;
if (op == 1){
int l, r;
cin >> l >> r;
l ^= (t * lastans);
r ^= (t * lastans);
if (l > r) swap(l, r);
seg.insert(MP(l, r));
vec_seg.emplace_back(l, r);
}
if (op == 2){
int id;
cin >> id;
--id;
seg.erase(vec_seg[id]);
}
if (op == 3){
int l, r, k;
cin >> l >> r >> k;
l ^= (t * lastans);
r ^= (t * lastans);
if (l > r) swap(l, r);
int ans = 0;
for (auto [a, b] : seg){
if (min(r, b) - max(l, a) + 1 >= k) ans++;
}
cout << ans << endl;
lastans = ans;
}
}
}
int main() {
startTime = clock();
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef dddxxz
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int TC = 1;
//cin >> TC;
for (int test = 1; test <= TC; test++) {
//debug(test);
//cout << "Case #" << test << ": ";
solve(test);
}
#ifdef dddxxz
cerr << endl << "Time: " << getCurrentTime() << " ms" << endl;
#endif
return 0;
}
Compilation message (stderr)
segments.cpp: In function 'void solve(int)':
segments.cpp:82:23: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
82 | for (auto [a, b] : seg){
| ^
# | 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... |