Codeforces Round #720 Nastia and a Hidden Permutation - Java/C++
Solution: For first type of query, every time we take x as n-1. For second type of query, every time we take x as 1.…
Solution: For first type of query, every time we take x as n-1. For second type of query, every time we take x as 1.…
A. Do Not Be Distracted! Solution: Scan the string. When we found a new letter, we skip the continually same letter. And mark this letter should not present…
Solution: We define the data structure below: static class Sheep { int suppose_pos, pos; } suppose_pos represent the position of this su…
Solution: This is a shortest paths problem. But do not use Dijkstra or SPFA to solve this problem. Because the time complex is $O(nm\cdot log(nm))$. Can get TLE with an extra $log$.…
Solution Base on the easy version, we still binary search in the hard version. So, we query the sum of $[1, mid]$.Now the problem is, after each time, we need change the element from 0 to 1.…
A. Phoenix and Gold Solution: If the sum of all numbers in w is x, then there is no solution. Because no matter what order, when $i=n$, the sum will be x.…
Solution: First. We can change $a_x + a_y = a_z + a_w$ to $a_x - a_w = a_z - a_y$. So the problem becomes a problem of finding two pairs so that their differ of each pair are equal.…
A. Red and Blue Beans Solution: Take the minimum value of $r$ and $b$ as $min$ and the maximum value as $max$.…