300808: CF154D. Flatland Fencing

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Flatland Fencing

题意翻译

一个独木桥上甲乙二人在玩传送游戏,其规则如下: 1.开始时,甲乙二人分别位于x1,x2处,且甲先手。 2.根据给定的参数a,b,二人可以在桥上传送:每一回合中,假定甲乙现在坐标为$x_1,x_2$,那么甲可以传送到[$x_1$+a,$x_1$+b]这一区间内的任一点上,而乙则可以传送到[$x_2$-b,$x_2$-a]上的任一点上,传送时允许跨越对手所在点(毕竟是传送)。 3.胜利的条件:在本方传送后成功到达对手所在点(把对手挤下桥)。 现问:在双方都足够聪明的情况下,谁会胜利? ---- 输出格式: 若甲胜利,输出“FIRST”,并在下一行指出此时甲第一步应该传送到的坐标。 若乙胜利,输出“SECOND”。 若比赛无法结束,输出“DRAW”。(注意:仅甲胜利时需要输出第二行。) ----- 数据: 输入仅一行四个整数:$x_1,x_2,a,b$。上述量均在$[-10^9,10^9]$范围内,且保证$a≤b$ * 特殊地,当a,b异号时,呆在原地不动也是合法操作。

题目描述

The King of Flatland will organize a knights' tournament! The winner will get half the kingdom and the favor of the princess of legendary beauty and wisdom. The final test of the applicants' courage and strength will be a fencing tournament. The tournament is held by the following rules: the participants fight one on one, the winner (or rather, the survivor) transfers to the next round. Before the battle both participants stand at the specified points on the $ Ox $ axis with integer coordinates. Then they make moves in turn. The first participant moves first, naturally. During a move, the first participant can transfer from the point $ x $ to any integer point of the interval \[ $ x+a $ ; $ x+b $ \]. The second participant can transfer during a move to any integer point of the interval \[ $ x-b $ ; $ x-a $ \]. That is, the options for the players' moves are symmetric (note that the numbers $ a $ and $ b $ are not required to be positive, and if $ a<=0<=b $ , then staying in one place is a correct move). At any time the participants can be located arbitrarily relative to each other, that is, it is allowed to "jump" over the enemy in any direction. A participant wins if he uses his move to transfer to the point where his opponent is. Of course, the princess has already chosen a husband and now she wants to make her sweetheart win the tournament. He has already reached the tournament finals and he is facing the last battle. The princess asks the tournament manager to arrange the tournament finalists in such a way that her sweetheart wins the tournament, considering that both players play optimally. However, the initial location of the participants has already been announced, and we can only pull some strings and determine which participant will be first and which one will be second. But how do we know which participant can secure the victory? Alas, the princess is not learned in the military affairs... Therefore, she asks you to determine how the battle will end considering that both opponents play optimally. Also, if the first player wins, your task is to determine his winning move.

输入输出格式

输入格式


The first line contains four space-separated integers — $ x_{1} $ , $ x_{2} $ , $ a $ and $ b $ ( $ x_{1}≠x_{2} $ , $ a<=b $ , $ -10^{9}<=x_{1},x_{2},a,b<=10^{9} $ ) — coordinates of the points where the first and the second participant start, and the numbers that determine the players' moves, correspondingly.

输出格式


On the first line print the outcome of the battle as "FIRST" (without the quotes), if both players play optimally and the first player wins. Print "SECOND" (without the quotes) if the second player wins and print "DRAW" (without the quotes), if nobody is able to secure the victory. If the first player wins, print on the next line the single integer $ x $ — the coordinate of the point where the first player should transfer to win. The indicated move should be valid, that is, it should meet the following condition: $ x_{1}+a<=x<=x_{1}+b $ . If there are several winning moves, print any of them. If the first participant can't secure the victory, then you do not have to print anything.

输入输出样例

输入样例 #1

0 2 0 4

输出样例 #1

FIRST
2

输入样例 #2

0 2 1 1

输出样例 #2

SECOND

输入样例 #3

0 2 0 1

输出样例 #3

DRAW

说明

In the first sample the first player can win in one move. In the second sample the first participant must go to point $ 1 $ , where the second participant immediately goes and wins. In the third sample changing the position isn't profitable to either participant, so nobody wins.

Input

题意翻译

一个独木桥上甲乙二人在玩传送游戏,其规则如下: 1.开始时,甲乙二人分别位于x1,x2处,且甲先手。 2.根据给定的参数a,b,二人可以在桥上传送:每一回合中,假定甲乙现在坐标为$x_1,x_2$,那么甲可以传送到[$x_1$+a,$x_1$+b]这一区间内的任一点上,而乙则可以传送到[$x_2$-b,$x_2$-a]上的任一点上,传送时允许跨越对手所在点(毕竟是传送)。 3.胜利的条件:在本方传送后成功到达对手所在点(把对手挤下桥)。 现问:在双方都足够聪明的情况下,谁会胜利? ---- 输出格式: 若甲胜利,输出“FIRST”,并在下一行指出此时甲第一步应该传送到的坐标。 若乙胜利,输出“SECOND”。 若比赛无法结束,输出“DRAW”。(注意:仅甲胜利时需要输出第二行。) ----- 数据: 输入仅一行四个整数:$x_1,x_2,a,b$。上述量均在$[-10^9,10^9]$范围内,且保证$a≤b$ * 特殊地,当a,b异号时,呆在原地不动也是合法操作。

加入题单

上一题 下一题 算法标签: