In 2018, hosted by Nanjing University of Aeronautics and Astronautics , the International Collegiate Programming Contest regional was held in Nanjing again after a few years' gap. There were over 400400400 teams in the contest and team Power of Two from Tsinghua University won the champion. Two years have passed and after the great success in 2018 and 2019, NUAA continues to hold the ICPC Nanjing Regional in 2020. Although we can't gather in Nanjing this time due to the pandemic, we should still be grateful for the hard work done by all staff and volunteers for this contest. Thank you all for your great contribution to this contest!
In 2018, hosted by Nanjing University of Aeronautics and Astronautics (NUAA), the International Collegiate Programming Contest (ICPC) regional was held in Nanjing again after a few years' gap. There were over 400400400 teams in the contest and team Power of Two from Tsinghua University won the champion. Two years have passed and after the great success in 2018 and 2019, NUAA continues to hold the ICPC Nanjing Regional in 2020. Although we can't gather in Nanjing this time due to the pandemic, we should still be grateful for the hard work done by all staff and volunteers for this contest. Thank you all for your great contribution to this contest! The 2018 ICPC Asia Nanjing Regional Contest In the 2018 contest, problem K, Kangaroo Puzzle, requires the contestants to construct an operation sequence for the game. Let's first recall the content of that problem: The puzzle is a grid with nnn rows and mmm columns (1≤n,m≤201 le n, m le 201≤n,m≤20) and there are some (at least 222) kangaroos standing in the puzzle. The player's goal is to control them to get together. There are some walls in some cells and the kangaroos cannot enter the cells with walls. The other cells are empty. The kangaroos can move from an empty cell to an adjacent empty cell in four directions: up, down, left, and right. It's guaranteed that kangaroos can reach from any empty cell to any other empty cells by going through adjacent empty cells. It is also guaranteed that there is no cycle in the puzzle -- that is, it's impossible that one kangaroo can move from an empty cell, pass by several distinct empty cells, and then back to the original cell. There is exactly one kangaroo in every empty cell in the beginning and the player can control the kangaroos by pressing the button U, D, L, R on the keyboard. The kangaroos will move simultaneously according to the button you press. For instance, if you press the button R, a kangaroo would move one cell to the right if it exists and is empty, and will stay still if it does not exist or is not empty. In this problem, the contestant needs to construct an operating sequence of at most 5×1045 times 10^45×104 steps consisting of U, D, L, R only. If after operating these steps in order there are still two kangaroos standing in different cells, the contestant will be given a "Wrong Answer" verdict. Our dear friend, Kotori, also took part in the contest and submitted a code of randomized algorithm. To her surprise, this simple solution is judged as a correct answer. We now present her solution as follows: #include