Almost Integer Rock Garden
ictor is building a Japanese rock garden in his square courtyard. He overlaid the courtyard with a Cartesian coordinate system so that any point in the courtyard has coordinates and . Victor wants to place stones in the garden according to the following rules: The center of each stone is located at some point , where and are integers . The coordinates of all twelve stones are pairwise distinct. The Euclidean distance from the center of any stone to the origin is not an integer. The s
View Solution →Sorted Subsegments
Consider an array of integers. We perform queries of the following type on : Sort all the elements in the subsegment . Given , can you find and print the value at index (where ) after performing queries? Input Format The first line contains three positive space-separated integers describing the respective values of (the number of integers in ), (the number of queries), and (an index in ). The next line contains space-separated integers describing the respective values of . E
View Solution →Distant Pairs
We take a line segment of length on a one-dimensional plane and bend it to create a circle with circumference that's indexed from to . For example, if : We denote a pair of points, and , as . We then plot pairs of points (meaning a total of individual points) at various indices along the circle's circumference. We define the distance between points and in pair as . Next, let's consider two pairs: and . We define distance as the minimum of the six distances between any two point
View Solution →King Richard's Knights
King Richard is leading a troop of knights into battle! Being very organized, he labels his knights and arranges them in an square formation, demonstrated below: Before the battle begins, he wants to test how well his knights follow instructions. He issues drill commands, where each command follows the format ai bi di and is executed like so: All knights in the square having the top-left corner at location and the bottom-right corner at location rotate in the clockwise direction. Re
View Solution →Sansa and XOR
Sansa has an array. She wants to find the value obtained by XOR-ing the contiguous subarrays, followed by XOR-ing the values thus obtained. Determine this value. Example Subarray Operation Result 3 None 3 4 None 4 5 None 5 3,4 3 XOR 4 7 4,5 4 XOR 5 1 3,4,5 3 XOR 4 XOR 5 2 Now we take the resultant values and XOR them together: . Return . Function Description Complete the sansaXor function in the editor below. sansaXor has the following parameter(s): int arr
View Solution →