Embercode
✕
Segment TreesQuick quiz

Dynamic trees and 2D sums

7 questions. Covers 2D prefix sums and 2D Fenwick trees.

Questions 1 to 5 of 7

  1. 1. What does this program print? ``cpp #include <iostream> #include <vector> int main() { std::vector<std::vector<long long>> g{{1, 2, 3}, {4, 5, 6}}; std::vector<std::vector<long long>> p(3, std::vector<long long>(4, 0)); for (std::size_t i = 0; i < 2; ++i) for (std::size_t j = 0; j < 3; ++j) p[i + 1][j + 1] = g[i][j] + p[i][j + 1] + p[i + 1][j] - p[i][j]; std::cout << p[2][3] - p[0][3] - p[2][1] + p[0][1] << '\n'; } ``
  2. 2. What does this program print? ``cpp #include <iostream> int main() { int rows = 10; int visits = 0; for (int i = 1; i <= rows; i += i & -i) ++visits; std::cout << visits << '\n'; } ``
  3. 3. After one insert into an empty dynamic segment tree that covers the values 0 to 1000000000, how many nodes are in use, with the root counted?
  4. 4. Why does the lesson 12 code write the midpoint as l + (r - l) / 2 instead of (l + r) / 2?
  5. 5. Which statements about the dynamic segment tree in lesson 12 are true?

    Pick every answer that is true.

5 question(s) left on this page.