Submission #928487

#TimeUsernameProblemLanguageResultExecution timeMemory
928487cadmiumskySegments (IZhO18_segments)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("Ofast,unroll-loops,O3") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,avx,abm,mmx,popcnt") #include <bits/stdc++.h> #define all(x) (x).begin(),(x).end() using namespace std; using ll = long long; using ld = long double; //#define int ll #define sz(x) ((int)(x).size()) using pii = pair<int,int>; using tii = tuple<int,int,int>; const int nmax = 2e5 + 5; pii segments[nmax]; struct Oper { char type; int a, b; int k; }; namespace Precalc { multiset<pii> actives_sortfwr; auto cmp = [](const pii& a, const pii& b) -> bool { return a.second < b.second || (a.second == b.second && a.first < b.first); }; multiset<pii, decltype(cmp)> actives_sortbckw(cmp); void rebatch(vector<Oper> opqueue) { for(auto [t, a, b, k] : opqueue) { if(t == 1) actives_sortfwr.insert(pii{a, b}), actives_sortbckw.insert(pii{a, b}); else if(t == 2) actives_sortfwr.erase(actives_sortfwr.find(segments[a])), actives_sortbckw.erase(actives_sortbckw.find(segments[a])); } return; } struct Item { int link; int sum, own; }; #warning theyre out here saying ca daca le tii in map direct e O(N) toata chestia #warning poate e doar Bmax sau ceva (700) (pt MLE sau cv) set<pii> fwrpoz; set<pii> bckwpoz; int freq[nmax]; Item fwr[nmax], bckw[nmax]; pii atrf[nmax], atrb[nmax]; map<int, int> norm_Ks; vector<int> currKs; int n; void contextualize(vector<int> Ks) { norm_Ks.clear(); for(auto x : Ks) norm_Ks[x]; int ptrnrm = 0; for(auto &[a, b] : norm_Ks) freq[ptrnrm] = 0, b = ptrnrm++; fwrpoz.clear(), bckwpoz.clear(); { // forward links pii lst = {-1, -1}; n = 0; for(auto [a, b] : actives_sortfwr) { int k = b - a + 1; if(k < Ks[0]) continue; if(pii{a, b} != lst) { n++; fwr[n].sum = fwr[n].own = 0; } atrf[n] = lst = pii{a, b}; fwr[n].own++; } vector<int> counter_app(sz(Ks)); for(int i = n, atrcoef = sz(Ks) - 1; i > 0; atrcoef = (atrcoef == 0? sz(Ks) - 1 : atrcoef - 1), i--) { auto [a, b] = atrf[i]; int poz = distance(begin(Ks), prev(upper_bound(all(Ks), b - a + 1))); counter_app[poz] += fwr[i].own; fwr[i].link = atrcoef; fwr[i].sum = counter_app[atrcoef]; fwrpoz.emplace(pii{a, i}); } } // ---- { // backward links pii lst = {-1, -1}; n = 0; for(auto [a, b] : actives_sortbckw) { int k = b - a + 1; if(k < Ks[0]) continue; if(pii{a, b} != lst) { n++; bckw[n].sum = bckw[n].own = 0; } atrb[n] = lst = pii{a, b}; bckw[n].own++; } vector<int> counter_app(sz(Ks)); for(int i = 1, atrcoef = sz(Ks) - 1; i <= n; atrcoef = (atrcoef == 0? sz(Ks) - 1 : atrcoef - 1), i++) { auto [a, b] = atrb[i]; int poz = distance(begin(Ks), prev(upper_bound(all(Ks), b - a + 1))); counter_app[poz] += bckw[i].own; bckw[i].link = atrcoef; bckw[i].sum = counter_app[atrcoef]; bckwpoz.emplace(pii{b, i}); } } for(auto [a, b] : actives_sortfwr) { int k = b - a + 1; if(k < Ks[0]) continue; freq[distance(begin(Ks), prev(upper_bound(all(Ks), k)))]++; } for(int i = sz(Ks) - 2; i >= 0; i--) freq[i] += freq[i + 1]; currKs = move(Ks); } int query_K(int k) { return freq[norm_Ks[k]]; } int query_L(int L, int k) { k = norm_Ks[k]; auto it = bckwpoz.upper_bound(pii{L + 1, - 1}); if(it == bckwpoz.begin()) return 0; int poz = prev(it) -> second, l = max(k, bckw[poz].link), r = l - 1; bool initially = l == k; int rez = 0; auto breakcondition = [&]() -> bool { if(initially) return r + 1 < sz(currKs); return k < l; }; auto belongcondition = [&](int len) -> bool { return (currKs[k] <= len && len < currKs[l]) || (r + 1 < sz(currKs) && currKs[r + 1] <= len); }; while(breakcondition() && poz > 0) { if(bckw[poz].link == r + 1) { rez += bckw[poz].sum; r++; } else if(bckw[poz].link == k) { rez += bckw[poz].sum; k++; } if(breakcondition() && belongcondition(atrb[poz].second - atrb[poz].first + 1)) rez += bckw[poz].own; poz--; } return rez; } int query_R(int R, int k) { k = norm_Ks[k]; auto it = fwrpoz.upper_bound(pii{R, - 1}); if(it == fwrpoz.end()) return 0; int poz = it -> second, l = max(k, fwr[poz].link), r = l - 1; bool initially = l == k; int rez = 0; auto breakcondition = [&]() -> bool { if(initially) return r + 1 < sz(currKs); return k < l; }; auto belongcondition = [&](int len) -> bool { return (currKs[k] <= len && len < currKs[l]) || (r + 1 < sz(currKs) && currKs[r + 1] <= len); }; while(breakcondition() && poz <= n) { if(fwr[poz].link == r + 1) { rez += fwr[poz].sum; r++; } else if(fwr[poz].link == k) { rez += fwr[poz].sum; k++; } if(breakcondition() && belongcondition(atrf[poz].second - atrf[poz].first + 1)) rez += fwr[poz].own; poz++; } return rez; } } //#error in loc sa ai pozitii care corespund unor segmente bune, doar pune suma partiala a alora congruenti cu (-pozitia) mod sz(Ks) int segmpoz = 1; int unitValue(int l, int r, int a, int b, int k) { return min(r, b) - max(l, a) + 1 >= k; } signed main() { cin.tie(0) -> sync_with_stdio(0); int n, t_offline; cin >> n >> t_offline; const int idealBuck = 512; const ll worstInner = (ll)idealBuck * n + 5; vector<Oper> operation_queue; operation_queue.reserve(n); vector<int> results; results.reserve(n); int lastans = 0; auto flush_queue = [&]() { vector<int> Ks; Ks.reserve(sz(operation_queue)); for(auto [t, a, b, k] : operation_queue) if(t == 3) Ks.emplace_back(k); if(sz(Ks) == 0) return; sort(all(Ks)); Ks.erase(unique(all(Ks)), Ks.end()); Precalc::contextualize(Ks); for(int i = 0; i < sz(operation_queue); i++) { auto &[ti, ai, bi, ki] = operation_queue[i]; if(ti == 1 || ti == 3) { ai = ai ^ (t_offline * lastans); bi = bi ^ (t_offline * lastans); if(ai > bi) swap(ai, bi); } if(ti == 1) segments[segmpoz++] = pii{ai, bi}; if(ti == 3) { if(bi - ai + 1 < ki) { lastans = 0; } else { int rez = Precalc::query_K(ki) - Precalc::query_R(bi - ki + 1 + 1, ki) - Precalc::query_L(ai + ki - 1 - 1, ki); for(int j = i - 1; j >= 0; j--) { auto &[tj, aj, bj, kj] = operation_queue[j]; if(tj == 3) continue; else if(tj == 2) rez -= unitValue(ai, bi, segments[aj].first, segments[aj].second, ki); else rez += unitValue(ai, bi, aj, bj, ki); } lastans = rez; } results.emplace_back(lastans); } } Precalc::rebatch(operation_queue); operation_queue.clear(); }; int cnt[2] = {1, 0}; for(int t, a, b, k, tc = 0; tc < n; tc++) { cin >> t; if(t == 1) { cin >> a >> b; operation_queue.emplace_back(Oper{t, a, b, -1}); cnt[0]++; } if(t == 2) { cin >> a; operation_queue.emplace_back(Oper{t, a, -1, -1}); cnt[0]++; } if(t == 3) { cin >> a >> b >> k; operation_queue.emplace_back(Oper{t, a, b, k}); cnt[1]++; } if(tc == n - 1 || (ll)cnt[1] * cnt[0] >= worstInner) { flush_queue(); cnt[1] = 0; cnt[0] = sz(Precalc::actives_sortbckw) * log2(log2(sz(Precalc::actives_sortbckw))); } } for(auto x : results) cout << x << '\n'; return 0; } /** Anul asta nu se da centroid -- Rugaciunile mele */ #include <bits/stdc++.h> #define all(x) (x).begin(),(x).end() using namespace std; using ll = long long; using ld = long double; //#define int ll #define sz(x) ((int)(x).size()) using pii = pair<int,int>; using tii = tuple<int,int,int>; const int nmax = 2e5 + 5; pii segments[nmax]; struct Oper { char type; int a, b; int k; }; namespace Precalc { multiset<pii> actives_sortfwr; auto cmp = [](const pii& a, const pii& b) -> bool { return a.second < b.second || (a.second == b.second && a.first < b.first); }; multiset<pii, decltype(cmp)> actives_sortbckw(cmp); void rebatch(vector<Oper> opqueue) { for(auto [t, a, b, k] : opqueue) { if(t == 1) actives_sortfwr.insert(pii{a, b}), actives_sortbckw.insert(pii{a, b}); else if(t == 2) actives_sortfwr.erase(actives_sortfwr.find(segments[a])), actives_sortbckw.erase(actives_sortbckw.find(segments[a])); } return; } struct Item { int link; int sum, own; }; #warning theyre out here saying ca daca le tii in map direct e O(N) toata chestia #warning poate e doar Bmax sau ceva (700) (pt MLE sau cv) set<pii> fwrpoz; set<pii> bckwpoz; int freq[nmax]; Item fwr[nmax], bckw[nmax]; pii atrf[nmax], atrb[nmax]; map<int, int> norm_Ks; vector<int> currKs; int n; void contextualize(vector<int> Ks) { norm_Ks.clear(); for(auto x : Ks) norm_Ks[x]; int ptrnrm = 0; for(auto &[a, b] : norm_Ks) freq[ptrnrm] = 0, b = ptrnrm++; fwrpoz.clear(), bckwpoz.clear(); { // forward links pii lst = {-1, -1}; n = 0; for(auto [a, b] : actives_sortfwr) { int k = b - a + 1; if(k < Ks[0]) continue; if(pii{a, b} != lst) { n++; fwr[n].sum = fwr[n].own = 0; } atrf[n] = lst = pii{a, b}; fwr[n].own++; } vector<int> counter_app(sz(Ks)); for(int i = n, atrcoef = sz(Ks) - 1; i > 0; atrcoef = (atrcoef == 0? sz(Ks) - 1 : atrcoef - 1), i--) { auto [a, b] = atrf[i]; int poz = distance(begin(Ks), prev(upper_bound(all(Ks), b - a + 1))); counter_app[poz] += fwr[i].own; fwr[i].link = atrcoef; fwr[i].sum = counter_app[atrcoef]; fwrpoz.emplace(pii{a, i}); } } // ---- { // backward links pii lst = {-1, -1}; n = 0; for(auto [a, b] : actives_sortbckw) { int k = b - a + 1; if(k < Ks[0]) continue; if(pii{a, b} != lst) { n++; bckw[n].sum = bckw[n].own = 0; } atrb[n] = lst = pii{a, b}; bckw[n].own++; } vector<int> counter_app(sz(Ks)); for(int i = 1, atrcoef = sz(Ks) - 1; i <= n; atrcoef = (atrcoef == 0? sz(Ks) - 1 : atrcoef - 1), i++) { auto [a, b] = atrb[i]; int poz = distance(begin(Ks), prev(upper_bound(all(Ks), b - a + 1))); counter_app[poz] += bckw[i].own; bckw[i].link = atrcoef; bckw[i].sum = counter_app[atrcoef]; bckwpoz.emplace(pii{b, i}); } } for(auto [a, b] : actives_sortfwr) { int k = b - a + 1; if(k < Ks[0]) continue; freq[distance(begin(Ks), prev(upper_bound(all(Ks), k)))]++; } for(int i = sz(Ks) - 2; i >= 0; i--) freq[i] += freq[i + 1]; currKs = move(Ks); } int query_K(int k) { return freq[norm_Ks[k]]; } int query_L(int L, int k) { k = norm_Ks[k]; auto it = bckwpoz.upper_bound(pii{L + 1, - 1}); if(it == bckwpoz.begin()) return 0; int poz = prev(it) -> second, l = max(k, bckw[poz].link), r = l - 1; bool initially = l == k; int rez = 0; auto breakcondition = [&]() -> bool { if(initially) return r + 1 < sz(currKs); return k < l; }; auto belongcondition = [&](int len) -> bool { return (currKs[k] <= len && len < currKs[l]) || (r + 1 < sz(currKs) && currKs[r + 1] <= len); }; while(breakcondition() && poz > 0) { if(bckw[poz].link == r + 1) { rez += bckw[poz].sum; r++; } else if(bckw[poz].link == k) { rez += bckw[poz].sum; k++; } if(breakcondition() && belongcondition(atrb[poz].second - atrb[poz].first + 1)) rez += bckw[poz].own; poz--; } return rez; } int query_R(int R, int k) { k = norm_Ks[k]; auto it = fwrpoz.upper_bound(pii{R, - 1}); if(it == fwrpoz.end()) return 0; int poz = it -> second, l = max(k, fwr[poz].link), r = l - 1; bool initially = l == k; int rez = 0; auto breakcondition = [&]() -> bool { if(initially) return r + 1 < sz(currKs); return k < l; }; auto belongcondition = [&](int len) -> bool { return (currKs[k] <= len && len < currKs[l]) || (r + 1 < sz(currKs) && currKs[r + 1] <= len); }; while(breakcondition() && poz <= n) { if(fwr[poz].link == r + 1) { rez += fwr[poz].sum; r++; } else if(fwr[poz].link == k) { rez += fwr[poz].sum; k++; } if(breakcondition() && belongcondition(atrf[poz].second - atrf[poz].first + 1)) rez += fwr[poz].own; poz++; } return rez; } } //#error in loc sa ai pozitii care corespund unor segmente bune, doar pune suma partiala a alora congruenti cu (-pozitia) mod sz(Ks) int segmpoz = 1; int unitValue(int l, int r, int a, int b, int k) { return min(r, b) - max(l, a) + 1 >= k; } signed main() { cin.tie(0) -> sync_with_stdio(0); int n, t_offline; cin >> n >> t_offline; const int idealBuck = 512; const ll worstInner = (ll)idealBuck * n + 5; vector<Oper> operation_queue; operation_queue.reserve(n); vector<int> results; results.reserve(n); int lastans = 0; auto flush_queue = [&]() { vector<int> Ks; Ks.reserve(sz(operation_queue)); for(auto [t, a, b, k] : operation_queue) if(t == 3) Ks.emplace_back(k); if(sz(Ks) == 0) return; sort(all(Ks)); Ks.erase(unique(all(Ks)), Ks.end()); Precalc::contextualize(Ks); for(int i = 0; i < sz(operation_queue); i++) { auto &[ti, ai, bi, ki] = operation_queue[i]; if(ti == 1 || ti == 3) { ai = ai ^ (t_offline * lastans); bi = bi ^ (t_offline * lastans); if(ai > bi) swap(ai, bi); } if(ti == 1) segments[segmpoz++] = pii{ai, bi}; if(ti == 3) { if(bi - ai + 1 < ki) { lastans = 0; } else { int rez = Precalc::query_K(ki) - Precalc::query_R(bi - ki + 1 + 1, ki) - Precalc::query_L(ai + ki - 1 - 1, ki); for(int j = i - 1; j >= 0; j--) { auto &[tj, aj, bj, kj] = operation_queue[j]; if(tj == 3) continue; else if(tj == 2) rez -= unitValue(ai, bi, segments[aj].first, segments[aj].second, ki); else rez += unitValue(ai, bi, aj, bj, ki); } lastans = rez; } results.emplace_back(lastans); } } Precalc::rebatch(operation_queue); operation_queue.clear(); }; int cnt[2] = {1, 0}; for(int t, a, b, k, tc = 0; tc < n; tc++) { cin >> t; if(t == 1) { cin >> a >> b; operation_queue.emplace_back(Oper{t, a, b, -1}); cnt[0]++; } if(t == 2) { cin >> a; operation_queue.emplace_back(Oper{t, a, -1, -1}); cnt[0]++; } if(t == 3) { cin >> a >> b >> k; operation_queue.emplace_back(Oper{t, a, b, k}); cnt[1]++; } if(tc == n - 1 || (ll)cnt[1] * cnt[0] >= worstInner) { flush_queue(); cnt[1] = 0; cnt[0] = sz(Precalc::actives_sortbckw) * log2(log2(sz(Precalc::actives_sortbckw))); } } for(auto x : results) cout << x << '\n'; return 0; } /** Anul asta nu se da centroid -- Rugaciunile mele */

Compilation message (stderr)

segments.cpp:49:4: warning: #warning theyre out here saying ca daca le tii in map direct e O(N) toata chestia [-Wcpp]
   49 |   #warning theyre out here saying ca daca le tii in map direct e O(N) toata chestia
      |    ^~~~~~~
segments.cpp:50:4: warning: #warning poate e doar Bmax sau ceva (700) (pt MLE sau cv) [-Wcpp]
   50 |   #warning poate e doar Bmax sau ceva (700) (pt MLE sau cv)
      |    ^~~~~~~
segments.cpp:349:4: warning: #warning theyre out here saying ca daca le tii in map direct e O(N) toata chestia [-Wcpp]
  349 |   #warning theyre out here saying ca daca le tii in map direct e O(N) toata chestia
      |    ^~~~~~~
segments.cpp:350:4: warning: #warning poate e doar Bmax sau ceva (700) (pt MLE sau cv) [-Wcpp]
  350 |   #warning poate e doar Bmax sau ceva (700) (pt MLE sau cv)
      |    ^~~~~~~
segments.cpp: In function 'int main()':
segments.cpp:274:42: warning: narrowing conversion of 't' from 'int' to 'char' [-Wnarrowing]
  274 |        operation_queue.emplace_back(Oper{t, a, b, -1});
      |                                          ^
segments.cpp:279:42: warning: narrowing conversion of 't' from 'int' to 'char' [-Wnarrowing]
  279 |        operation_queue.emplace_back(Oper{t, a, -1, -1});
      |                                          ^
segments.cpp:284:42: warning: narrowing conversion of 't' from 'int' to 'char' [-Wnarrowing]
  284 |        operation_queue.emplace_back(Oper{t, a, b, k});
      |                                          ^
segments.cpp: At global scope:
segments.cpp:316:11: error: redefinition of 'const int nmax'
  316 | const int nmax = 2e5 + 5;
      |           ^~~~
segments.cpp:16:11: note: 'const int nmax' previously defined here
   16 | const int nmax = 2e5 + 5;
      |           ^~~~
segments.cpp:318:5: error: redefinition of 'pii segments [200005]'
  318 | pii segments[nmax];
      |     ^~~~~~~~
segments.cpp:18:5: note: 'pii segments [200005]' previously defined here
   18 | pii segments[nmax];
      |     ^~~~~~~~
segments.cpp:320:8: error: redefinition of 'struct Oper'
  320 | struct Oper {
      |        ^~~~
segments.cpp:20:8: note: previous definition of 'struct Oper'
   20 | struct Oper {
      |        ^~~~
segments.cpp:327:17: error: redefinition of 'std::multiset<std::pair<int, int> > Precalc::actives_sortfwr'
  327 |   multiset<pii> actives_sortfwr;
      |                 ^~~~~~~~~~~~~~~
segments.cpp:27:17: note: 'std::multiset<std::pair<int, int> > Precalc::actives_sortfwr' previously declared here
   27 |   multiset<pii> actives_sortfwr;
      |                 ^~~~~~~~~~~~~~~
segments.cpp:329:8: error: conflicting declaration 'auto Precalc::cmp'
  329 |   auto cmp = [](const pii& a, const pii& b) -> bool { return a.second < b.second || (a.second == b.second && a.first < b.first); };
      |        ^~~
segments.cpp:29:8: note: previous declaration as 'Precalc::<lambda(const pii&, const pii&)> Precalc::cmp'
   29 |   auto cmp = [](const pii& a, const pii& b) -> bool { return a.second < b.second || (a.second == b.second && a.first < b.first); };
      |        ^~~
segments.cpp:330:32: error: redefinition of 'std::multiset<std::pair<int, int>, Precalc::<lambda(const pii&, const pii&)> > Precalc::actives_sortbckw'
  330 |   multiset<pii, decltype(cmp)> actives_sortbckw(cmp);
      |                                ^~~~~~~~~~~~~~~~
segments.cpp:30:32: note: 'std::multiset<std::pair<int, int>, Precalc::<lambda(const pii&, const pii&)> > Precalc::actives_sortbckw' previously declared here
   30 |   multiset<pii, decltype(cmp)> actives_sortbckw(cmp);
      |                                ^~~~~~~~~~~~~~~~
segments.cpp:332:8: error: redefinition of 'void Precalc::rebatch(std::vector<Oper>)'
  332 |   void rebatch(vector<Oper> opqueue) {
      |        ^~~~~~~
segments.cpp:32:8: note: 'void Precalc::rebatch(std::vector<Oper>)' previously defined here
   32 |   void rebatch(vector<Oper> opqueue) {
      |        ^~~~~~~
segments.cpp:344:10: error: redefinition of 'struct Precalc::Item'
  344 |   struct Item {
      |          ^~~~
segments.cpp:44:10: note: previous definition of 'struct Precalc::Item'
   44 |   struct Item {
      |          ^~~~
segments.cpp:352:12: error: redefinition of 'std::set<std::pair<int, int> > Precalc::fwrpoz'
  352 |   set<pii> fwrpoz;
      |            ^~~~~~
segments.cpp:52:12: note: 'std::set<std::pair<int, int> > Precalc::fwrpoz' previously declared here
   52 |   set<pii> fwrpoz;
      |            ^~~~~~
segments.cpp:353:12: error: redefinition of 'std::set<std::pair<int, int> > Precalc::bckwpoz'
  353 |   set<pii> bckwpoz;
      |            ^~~~~~~
segments.cpp:53:12: note: 'std::set<std::pair<int, int> > Precalc::bckwpoz' previously declared here
   53 |   set<pii> bckwpoz;
      |            ^~~~~~~
segments.cpp:354:7: error: redefinition of 'int Precalc::freq [200005]'
  354 |   int freq[nmax];
      |       ^~~~
segments.cpp:54:7: note: 'int Precalc::freq [200005]' previously declared here
   54 |   int freq[nmax];
      |       ^~~~
segments.cpp:355:8: error: redefinition of 'Precalc::Item Precalc::fwr [200005]'
  355 |   Item fwr[nmax], bckw[nmax];
      |        ^~~
segments.cpp:55:8: note: 'Precalc::Item Precalc::fwr [200005]' previously declared here
   55 |   Item fwr[nmax], bckw[nmax];
      |        ^~~
segments.cpp:355:19: error: redefinition of 'Precalc::Item Precalc::bckw [200005]'
  355 |   Item fwr[nmax], bckw[nmax];
      |                   ^~~~
segments.cpp:55:19: note: 'Precalc::Item Precalc::bckw [200005]' previously declared here
   55 |   Item fwr[nmax], bckw[nmax];
      |                   ^~~~
segments.cpp:356:7: error: redefinition of 'pii Precalc::atrf [200005]'
  356 |   pii atrf[nmax], atrb[nmax];
      |       ^~~~
segments.cpp:56:7: note: 'pii Precalc::atrf [200005]' previously defined here
   56 |   pii atrf[nmax], atrb[nmax];
      |       ^~~~
segments.cpp:356:19: error: redefinition of 'pii Precalc::atrb [200005]'
  356 |   pii atrf[nmax], atrb[nmax];
      |                   ^~~~
segments.cpp:56:19: note: 'pii Precalc::atrb [200005]' previously defined here
   56 |   pii atrf[nmax], atrb[nmax];
      |                   ^~~~
segments.cpp:357:17: error: redefinition of 'std::map<int, int> Precalc::norm_Ks'
  357 |   map<int, int> norm_Ks;
      |                 ^~~~~~~
segments.cpp:57:17: note: 'std::map<int, int> Precalc::norm_Ks' previously declared here
   57 |   map<int, int> norm_Ks;
      |                 ^~~~~~~
segments.cpp:358:15: error: redefinition of 'std::vector<int> Precalc::currKs'
  358 |   vector<int> currKs;
      |               ^~~~~~
segments.cpp:58:15: note: 'std::vector<int> Precalc::currKs' previously declared here
   58 |   vector<int> currKs;
      |               ^~~~~~
segments.cpp:360:7: error: redefinition of 'int Precalc::n'
  360 |   int n;
      |       ^
segments.cpp:60:7: note: 'int Precalc::n' previously declared here
   60 |   int n;
      |       ^
segments.cpp:362:8: error: redefinition of 'void Precalc::contextualize(std::vector<int>)'
  362 |   void contextualize(vector<int> Ks) {
      |        ^~~~~~~~~~~~~
segments.cpp:62:8: note: 'void Precalc::contextualize(std::vector<int>)' previously defined here
   62 |   void contextualize(vector<int> Ks) {
      |        ^~~~~~~~~~~~~
segments.cpp:437:7: error: redefinition of 'int Precalc::query_K(int)'
  437 |   int query_K(int k) {
      |       ^~~~~~~
segments.cpp:137:7: note: 'int Precalc::query_K(int)' previously defined here
  137 |   int query_K(int k) {
      |       ^~~~~~~
segments.cpp:440:7: error: redefinition of 'int Precalc::query_L(int, int)'
  440 |   int query_L(int L, int k) {
      |       ^~~~~~~
segments.cpp:140:7: note: 'int Precalc::query_L(int, int)' previously defined here
  140 |   int query_L(int L, int k) {
      |       ^~~~~~~
segments.cpp:467:7: error: redefinition of 'int Precalc::query_R(int, int)'
  467 |   int query_R(int R, int k) {
      |       ^~~~~~~
segments.cpp:167:7: note: 'int Precalc::query_R(int, int)' previously defined here
  167 |   int query_R(int R, int k) {
      |       ^~~~~~~
segments.cpp:497:5: error: redefinition of 'int segmpoz'
  497 | int segmpoz = 1;
      |     ^~~~~~~
segments.cpp:197:5: note: 'int segmpoz' previously defined here
  197 | int segmpoz = 1;
      |     ^~~~~~~
segments.cpp:499:5: error: redefinition of 'int unitValue(int, int, int, int, int)'
  499 | int unitValue(int l, int r, int a, int b, int k) {
      |     ^~~~~~~~~
segments.cpp:199:5: note: 'int unitValue(int, int, int, int, int)' previously defined here
  199 | int unitValue(int l, int r, int a, int b, int k) {
      |     ^~~~~~~~~
segments.cpp:503:8: error: redefinition of 'int main()'
  503 | signed main() {
      |        ^~~~
segments.cpp:203:8: note: 'int main()' previously defined here
  203 | signed main() {
      |        ^~~~
segments.cpp: In function 'int main()':
segments.cpp:574:42: warning: narrowing conversion of 't' from 'int' to 'char' [-Wnarrowing]
  574 |        operation_queue.emplace_back(Oper{t, a, b, -1});
      |                                          ^
segments.cpp:579:42: warning: narrowing conversion of 't' from 'int' to 'char' [-Wnarrowing]
  579 |        operation_queue.emplace_back(Oper{t, a, -1, -1});
      |                                          ^
segments.cpp:584:42: warning: narrowing conversion of 't' from 'int' to 'char' [-Wnarrowing]
  584 |        operation_queue.emplace_back(Oper{t, a, b, k});
      |                                          ^