{"problem":{"name":"189. Journey to the Exoplanets","description":{"content":"You're on an intergalactic space mission in the year 2100, and you come across a star with several planets orbiting it. You know the coordinates of each planet in 3D space, and given this information,","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10269189"},"statements":[{"statement_type":"Markdown","content":"You're on an intergalactic space mission in the year 2100, and you come across a star with several planets orbiting it. You know the coordinates of each planet in 3D space, and given this information, you need to find the ordering of the planets from closest to farthest away from the star. Then, you can figure out which planets are most likely to have alien life forms.\n\nYou're given the coordinates of the star of the planetary system, and the coordinates for $n$ planets orbiting the star, and their names.\n\nRecall that you can use the 3D distance formula to calculate the distance between two planets in 3D space:\n\nThe first line of input consists of three space-separated integers: the X, Y, and Z coordinates of the star, respectively.\n\nThe next line of input contains a single positive integer $n$: the number of planets orbiting the star.\n\nThe next $n$ lines each contain three space-separated integers, representing the X, Y, and Z coordinates of each planet, respectively, followed by a space and a single string, representing the name of the planet.\n\nNo two planets in the input file will have the same distance away from the star.\n\nOutput $n$ lines: the names of each planet in the exoplanetary system, ordered based on their distance from the star. The planet closest to the star should come first in the list, and the planet the furthest away from the star should come last in the list.\n\n## Input\n\nThe first line of input consists of three space-separated integers: the X, Y, and Z coordinates of the star, respectively.The next line of input contains a single positive integer $n$: the number of planets orbiting the star.The next $n$ lines each contain three space-separated integers, representing the X, Y, and Z coordinates of each planet, respectively, followed by a space and a single string, representing the name of the planet.No two planets in the input file will have the same distance away from the star.\n\n## Output\n\nOutput $n$ lines: the names of each planet in the exoplanetary system, ordered based on their distance from the star. The planet closest to the star should come first in the list, and the planet the furthest away from the star should come last in the list.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ S = (x_s, y_s, z_s) \\in \\mathbb{R}^3 $ be the coordinates of the star.  \nLet $ P = \\{ (x_i, y_i, z_i, \\text{name}_i) \\mid i \\in \\{1, \\dots, n\\} \\} $ be the set of planets, where $ (x_i, y_i, z_i) \\in \\mathbb{R}^3 $ are the coordinates and $ \\text{name}_i \\in \\mathbb{S} $ is the planet's name.\n\n**Constraints**  \n1. $ n \\in \\mathbb{Z}^+ $  \n2. All planet distances from $ S $ are distinct.\n\n**Objective**  \nFor each planet $ i $, compute the Euclidean distance:  \n$$ d_i = \\sqrt{(x_i - x_s)^2 + (y_i - y_s)^2 + (z_i - z_s)^2} $$  \nOutput the names $ \\text{name}_i $ sorted in increasing order of $ d_i $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10269189","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}