øεWsàŸ}`âεUIεX-nOt}àîX‚}{н
@ Pietu1998的Jelly答案端口。
在线尝试或验证所有测试用例。
说明:
ø # Zip the (implicit) input, swapping the rows and column
# i.e. [[1,4],[3,2],[3,1]] → [[1,3,3],[4,2,1]]
ε } # Map each to:
W # Push the smallest value (without popping the list)
# i.e. [[1,3,3],[4,2,1]] → [1,1]
s # Swap so the list is at the top of the stack again
à # Pop the list and push the largest value
# i.e. [[1,3,3],[4,2,1]] → [3,4]
Ÿ # Take the inclusive range of the min and max
# i.e. [[1,2,3],[1,2,3,4]]
` # After the map, push both lists separated to the stack
â # And take the cartesian product of the two lists
# i.e. [[1,2,3],[1,2,3,4]]
# → [[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4]]
ε } # Map each pair to:
U # Pop and store the current value in variable `X`
I # Push the input
ε } # Map each pair in the input to:
X # Push variable `X`
- # Subtract it from the current pair
# i.e. [3,2] - [1,3] → [2,-1]
n # Take the square of each
# i.e. [2,-1] → [4,1]
O # Sum the lists
# i.e. [4,1] → 5
t # Take the square-root of each
# i.e. 5 → 2.23606797749979
à # Pop the converted list, and push its largest value
# i.e. [[3.0,2.23606797749979,2.0],[2.0,2.0,2.23606797749979],...,[2.0,2.0,3.0]]
# → [3.0,2.23606797749979,...,3.0]
î # Round it up
# i.e. [3.0,2.23606797749979,...,3.0] → [3.0,3.0,3.0,4.0,4.0,3.0,3.0,4.0,4.0,3.0,3.0,3.0]
X‚ # Pair it with variable `X`
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]]
{ # After the map, sort the list
н # And take the first item (which is output implicitly)
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]] → [3.0,[1,1]]