#C8140. Magic Hexagon Possibility Checker
Magic Hexagon Possibility Checker
Magic Hexagon Possibility Checker
In this problem, you are given a size parameter (n) and a list of numbers. Your task is to determine if it is possible to arrange these numbers into a Magic Hexagon of size (n). The rules are as follows:
- When \(n = 2\), the numbers must exactly be the set \(\{1,2,3,4,5,6,7,8,9,10\}\) (order does not matter) to output YES.
- When \(n = 3\), even if the numbers form the set \(\{1,2,...,26\}\), you must output NO.
- For any other cases or if the conditions are not met, output NO.
The input consists of multiple test cases. Each test case is provided on a new line. The first integer in each line is (n) followed by the associated list of numbers. The input terminates with a line containing -1
.
inputFormat
Input is read from standard input (stdin). Each test case is a single line containing space-separated integers. The first integer represents (n) and the following integers are the list of numbers. The input ends with a line containing -1
.
outputFormat
For each test case, output a single line on standard output (stdout) with either YES or NO based on whether the conditions are met.## sample
2 1 2 3 4 5 6 7 8 9 10
3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
-1
YES
NO
</p>