|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||2||2||2||100.000%|
A clan of ninjas have hit upon a strange map: it is divided into squares of size 0.5 by 0.5 inch approximately. Somewhere in the middle, on a spot known to be a foothold of pirates, the square is denoted by 1, while the adjacent squares from north to west bear the numbers 2, 3, 5, and 4, respectively. This strange numbering puzzled the ninjas for a long time until the brightest gambler among them discovered that it had something to do with dice: if the top shows 1, and you roll – or rather tilt – the die to the right onto the neighboring square, then 3 appears on top (depending of course on the orientation of the die.) Together with the map, they laid their hands on a strange text first attributed to the Bay Area Poets Coalition, but it seemed unlikely that even Joyce concocted such a hermetic verse.
The first sentence reads “5X-YYX+Y.”. They found out what it means:
The minus sign means that the directions are reversed (east becomes west and north becomes south), the plus sign restores the original directions. The sequence ends with a dot ’.’. The number of dots on the top of the die in its final position signifies what is to find on this spot: a hut, a hiding place for weapons, a well, or even a place of unspeakable horror.
Your task is to compute the coordinates of the final position (relative to the starting point) and to determine what number of dots is shown on the top.
The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format:
A sequence can contain digits, ’+’, ’-’, ’X’, ’Y’, and ends with a dot. A sequence contains at most 1000 characters. The numbers in the sequence consist of at most 7 digits and are never zero.
For every test case in the input, the output should be a single line containing “position (x, y), z dots”, where (x, y) is the final position of the die and z the number of dots shown on top of the die in the final position.
3 5X-YYX+Y. XY-XY. 12X12Y-12X12Y.
position (4,-1), 5 dots position (0,0), 3 dots position (0,0), 1 dots