MCU20A - The Triangle Game
In the triangle game you start off with six triangles numbered on each edge, as in the example above. You can slide and rotate the triangles so they form a hexagon, but the hexagon is only legal if edges common to two triangles have the same number on them. You may not flip any triangle over. Two legal hexagons formed from the six triangles are illustrated below.
The score for a legal hexagon is the sum of the numbers on the outside six edges.
Your problem is to find the highest score that can be achieved with any six particular triangles.
The input file will contain one or more data sets. Each data set is a sequence of six lines with three integers from 1 to 100 separated by blanks on each line. Each line contains the numbers on the triangles in clockwise order. Data sets are separated by a line containing only an asterisk. The last data set is followed by a line containing only a dollar sign.
For each input data set, the output is a line containing only the word "none" if there are no legal hexagons or the highest score if there is a legal hexagon.
Example
Input: 1 4 20 3 1 5 50 2 3 5 2 7 7 5 20 4 7 50 * 10 1 20 20 2 30 30 3 40 40 4 50 50 5 60 60 6 10 * 10 1 20 20 2 30 30 3 40 40 4 50 50 5 60 10 6 60 $ Output: 152 21 none
hide comments
David:
2021-11-17 21:54:44
For pictures, see: http://poj.org/problem?id=1574
|
|
:D:
2018-10-16 01:36:37
Easy but fun problem. Surprising it has so few ACs. |
|
Apoorv Jindal:
2013-12-24 20:40:54
Saw this problem like a month ago. Couldn't solve it then.Could code it now.Thanks to spoj, it is helping me grow :) |
|
biQar:
2013-09-18 14:32:46
why print "none" for the last input ? Can anyone please explain it to me ?
|
Added by: | abdelkarim |
Date: | 2013-09-16 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Mid-Central USA 2000 |