ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

USU Championship 2008

About     Problems     Submit solution     Judge status     Standings
Contest is over

J. Triangle Game 2

Time limit: 1.0 second
Memory limit: 64 MB
Years have passed. Generations have changed. New students play the triangle game at all universities. But Dima and Sasha have been unlucky so many times that they still play this strange game.
Dima has a map of Yekaterinozavodsk on his table, and three strategic points are marked on the map: (x1, y1) is the Yekaterinozavodsk State University, (x2, y2) is the sushi bar Karelskaya Gornitsa, and (x3, y3) is the T34 entertainment center, where Dima and Sasha play Russian billiards. These points and the segments that connect them form a nondegenerate triangle, and an equal triangular chip is cut out from a cardboard sheet. The goal of the players is to transfer the chip in several moves to the marked triangle. Each move consists in applying symmetry with respect to some axis to the chip. You may assume that during the game the chip always remains within the bounds of the map. Sasha wants to determine the minimal number of moves needed for finishing the game.


The first line contains the integers x1, y1, x2, y2, x3, y3. The second line contains the current coordinates of the chip: X1, Y1, X2, Y2, X3, Y3. The absolute values of all numbers do not exceed 2000.


If it is impossible to move the chip so that it would coincide with the triangle, output “IMPOSSIBLE”. Otherwise, output the minimal possible number of moves in which this can be done.


4 0 6 3 7 0
0 0 2 3 3 0


In the sample, the first symmetry applied to the chip can be the symmetry with respect to the line x = 2, and the second, with respect to the line x = 4.
Problem Author: Alexander Ipatov
Problem Source: XIII Open USU Championship
To submit the solution for this problem go to the Problem set: 1637. Triangle Game 2