제출 #960978

#제출 시각아이디문제언어결과실행 시간메모리
960978pragmatistSegments (IZhO18_segments)C++17
75 / 100
5095 ms4824 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5+7; const int K = 1000; int n, t; pair<int, int> a[N]; struct Data { int l, r, x; }; vector<Data> add; int get(int l, int r, int k) { if(r-l+1<k) { return 0; } int res = 0; for(auto [c, d, x] : add) { int len = min(d, r)-max(l, c)+1; if(len >= k) { res += x; } } return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> t; int ans = 0, timer = 0; for(int i = 1; i <= n; ++i) { char tp; cin >> tp; if(tp == '1') { int l, r; cin >> l >> r; l = (l^(t*ans)); r = (r^(t*ans)); if(l>r) { swap(l, r); } a[++timer] = {l, r}; add.push_back({l, r, 1}); } else if(tp == '2') { int id; cin >> id; add.push_back({a[id].first, a[id].second, -1}); } else { int l, r, k; cin >> l >> r >> k; l = (l^(t*ans)); r = (r^(t*ans)); if(l>r) { swap(l, r); } cout << (ans = get(l, r, k)) << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...