Submission #893667

#TimeUsernameProblemLanguageResultExecution timeMemory
893667vjudge1Segments (IZhO18_segments)C++17
0 / 100
5026 ms10004 KiB
// 以上帝的名义 // 候选硕士 #include <bits/stdc++.h> #ifdef local #include "algo/debug.h" #else #define dbg(x...) 0 #endif using namespace std ; using ll = long long ; using ld = long double ; struct Fenwick { vector<ll> t ; int n; Fenwick(int len) { n = len ; t.assign(n + 1, 0) ; } void upd(int i, ll x) { while (i <= n) { t[i] += x; i += (i & (-i)) ; } } ll get(int i) { ll sum = 0 ; while (i) { sum += t[i] ; i -= (i & (-i)) ; } return sum ; } ll get(int l, int r) { return get(r) - get(l - 1) ; } }; int32_t main() { ios::sync_with_stdio(false) ; cin.tie(nullptr) ; int n , t; cin >> n >> t ; int last = 0 ; int idx = 0 ; pair<int,int> pr[n + 1] ; multiset<pair<int,int>> s ; Fenwick f(n * 5) ; for (int i = 0 ; i < n ; i++) { int cmd ; cin >> cmd ; if (cmd == 1) { int a , b; cin >> a >> b ; int l = (a ^ (t * last)) ; int r = (b ^ (t * last)) ; if (l > r) swap(l, r) ; pr[++idx]= {l, r} ; for (int j = l ; j <= r ; j++) f.upd(j, 1) ; } else if (cmd == 2) { int ind ; cin >> ind ; auto c = pr[ind] ; for (int j = c.first ; j <= c.second ; j++) f.upd(j, -1) ; } else { int a, b, k ; cin >> a >> b >> k ; int l = (a ^ (last * t)) ; int r = (b ^ (last * t)) ; cout << "query -> " << l << ' ' << r << " " << k << "\n" ; if (l > r) swap(l, r) ; ll sum = f.get(l, r) ; sum = (sum) / k ; cout << sum << "\n" ; last = sum ; } } 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...