H. Kawal Pemilu
Author: Felix Halim
Prepared By: Felix Halim, Ilham Winata Kurnia, Suhendry Effendy
(link to problem H)
As you might have noticed (above), this problem is proposed by one of the programmer behind kawalpemilu.org. He (implicitly) said that this problem is motivated by one question in QUORA asking about the custom in-memory database structure used by kawalpemilu. I guess the solution to this problem is the answer to that question.
The administrative divisions can be represented by a rooted tree, where the root is the national region. Each node X has a child Y iff Y lies within X region and their level differ by exactly 1. Implementation-wise, you don’t need to construct the tree; all you need is only the immediate parent information for each node (one parent for each node). Each node should keep the votes count on its region, such that when there is a query of the 2nd type, the answer can be obtained in O(1) – just retrieve the votes count (from an array, for example). When there is a query of the 1st type (incoming votes), you need to update the votes count from the node (village) to all its predecessors until the root. Notice that there are only 5 levels of administrative regions, thus the tree depth will also be 5.
There are 114 submissions have been made for this problem, in which 50 teams managed to get accepted. The first team who solve this problem is BerinGAS (minute 36) from University of Indonesia.