Problem 22537 --Balloons Colors
22537: Balloons ColorsTime Limit: 1 Sec Memory Limit: 128 MB
Submit: 2 Solved: 1
Assigning a balloon color to each problem is one of the tasks we need to do every year, and sometimes it
We noticed that some contestants assume some colors for some problems according to the difficulty. For
example, the easiest problem is the red one and the hardest problem is the black one.
We do not want these assumptions to be true, so we decided to add constraints for the easiest and the
There areNproblems, numbered from 1 toN, the easiest problem is problem number 1, and the hardest
problem is problem numberN. Also there are Nunique colors, for simplicity we will give each color a
unique number from 1 to N.
We want to assign each color to exactly 1 problem, such that the easiest problem does not get the color
Xand the hardest problem does not get the colorY.
GivenN, X, Yand an assignment of the colors, your task is to nd if this assignment satises the above
conditions or not.
Your program will be tested on one or more test cases. The rst line of the input will be a single integerT,
the number of test cases (1<=T<=100). Followed by the test cases, the rst line of each test case contains
3 integers separated by a single spaceN X Y(3 <=N<=100) and (1<=X, Y<=N) representing the
number of problems, the color which the easiest problem should not get and the color which the hardest
problem should not get, respectively. Followed by a line which containsNintegers separated by a single
space (each integer from 1 to Nshould appear exactly once), the rst integer is the color for the rst
problem (the easiest), the second integer is the color for the second problem and so on (the last integer is
the color for the hardest problem).
For each test case, print a single line which contains a single word, this word should be (without the
- BOTH: If both the easiest and hardest problems got colors which they should not get.
- EASY: If only the easiest problem got a color which it should not get.
- HARD: If only the hardest problem got a color which it should not get.
- OKAY: If both the easiest and hardest problems got colors which they can get.
3 1 2
1 3 2
5 3 4
3 1 2 4 5
6 1 6
2 1 3 4 5 6
7 7 7
1 7 2 3 4 5 6