MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/Segment Tree/basic.cpp:68–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68int main()
69{
70#ifndef ONLINE_JUDGE
71 freopen("E:/Code/DSA/input.txt", "r", stdin);
72 freopen("E:/Code/DSA/output.txt", "w", stdout);
73#endif
74 int n;
75 cin >> n;
76 vector<int> nums(n);
77 for (int i = 0; i < n; i++)
78 {
79 cin >> nums[i];
80 }
81 vector<int> tree(4 * n);
82 buildTree(nums, tree);
83 cout << getSum(nums, tree, 0, 1) << endl;
84 cout << getSum(nums, tree, 0, 0) << endl;
85 cout << getSum(nums, tree, 0, 2) << endl;
86 cout << getSum(nums, tree, 0, 3) << endl;
87 cout << getSum(nums, tree, 1, 3) << endl;
88 cout << getSum(nums, tree, 2, 3) << endl;
89 cout << getSum(nums, tree, 3, 3) << endl;
90 cout << getSum(nums, tree, 1, 2) << endl;
91 cout << getSum(nums, tree, 2, 2) << endl;
92 update(nums, tree, 1, 25);
93 return 0;
94}

Callers

nothing calls this directly

Calls 3

updateFunction · 0.85
buildTreeFunction · 0.70
getSumFunction · 0.70

Tested by

no test coverage detected