|
|||
LogoLogo is a programming language built around a turtle. Commands in the language cause the turtle to move. The turtle has a pen attached to it. As the turtle moves, it draws lines on the page. The turtle can be programmed to draw interesting pictures. We are interested in making the turtle draw a picture, then return to the point that it started from. For example, we could give the turtle the following program:
The command After executing many commands, the turtle can get lost, far away from its starting position. Your task is to determine the straight-line distance from the turtle's position at the end of its journey back to the position that it started from. Input SpecificationThe first line of the input contains one integer specifying the number of test cases to follow. Each test case starts with a line containing one integer, the number of commands to follow. The commands follow, one on each line. Each test case will contain no more than 1000 commands. Output SpecificationFor each test case, output a line containing a single integer, the distance rounded to the nearest unit. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |