Submission #500763

#TimeUsernameProblemLanguageResultExecution timeMemory
500763pragmatistSegments (IZhO18_segments)C++17
7 / 100
78 ms736 KiB
#include <bits/stdc++.h> #define pb push_back #define sz(v) (int)v.size() #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define x first #define y second #define int long long #define nl "\n" using namespace std; typedef long long ll; typedef pair<long long, long long> pll; typedef pair <ll, ll> pii; const int N = (int)5e4 + 7; const int M = (int)7e6 + 7; const ll MOD = (ll)1e9 + 7; const int inf = (int)1e9 + 7; const ll INF = (ll)3e18 + 7; pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}}; int n, t; pii p[5001]; void solve() { cin >> n >> t; for(int i = 1; i <= n; ++i) p[i] = {-1, -1}; multiset<pair<pii, int> > s; int ans = 0; while(n--) { char tp; cin >> tp; int l, r, k; if(tp == '1') { cin >> l >> r; l = (l ^ (t * ans)), r = (r ^ (t * ans)); if(l > r) swap(l, r); int id = 0; for(int i = 1; i <= 5000; ++i) { if(p[i].x == -1) { id = i; break; } } p[id] = {l, r}; s.insert({{l, r}, id}); } else if(tp == '2') { int id; cin >> id; s.erase({{p[id].x, p[id].y}, id}); } else { cin >> l >> r >> k; l = (l ^ (t * ans)), r = (r ^ (t * ans)); if(l > r) swap(l, r); int cnt = 0; for(auto e : s) { int x = e.x.x, y = e.x.y; int cur = 0; cur = max(0ll, min(y, r) - max(l, x) + 1); if(cur >= k) cnt++; } ans = cnt; cout << ans << nl; } } } signed main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); int test = 1; //cin >> test; for(int i = 1; i <= test; ++i) { //cout << "Case " << i << ": "; solve(); } return 0; } /* 6 1 1 1 2 3 2 4 2 1 3 5 3 2 3 1 2 1 3 0 3 1 6 0 1 3 10 1 3 5 3 6 10 6 2 1 1 3 10 3 6 4 2 */
#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...