MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / split

Function split

code/data-structures/sqrt_decomposition.cpp:19–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 T.push_back(segment(vi(arr.begin()+i,
18 arr.begin()+min(i+K, cnt)))); }
19int split(int at) {
20 int i = 0;
21 while (i < size(T) && at >= size(T[i].arr))
22 at -= size(T[i].arr), i++;
23 if (i >= size(T)) return size(T);
24 if (at == 0) return i;
25 T.insert(T.begin() + i + 1,
26 segment(vi(T[i].arr.begin() + at, T[i].arr.end())));
27 T[i] = segment(vi(T[i].arr.begin(), T[i].arr.begin() + at));
28 return i + 1; }
29void insert(int at, int v) {
30 vi arr; arr.push_back(v);
31 T.insert(T.begin() + split(at), segment(arr)); }

Callers 2

insertFunction · 0.70
eraseFunction · 0.70

Calls 2

segmentClass · 0.70
insertMethod · 0.45

Tested by

no test coverage detected