H. Dreams Were Important Too!

Codeforces
IDCF10053H
Time3000ms
Memory256MB
Difficulty
English · Original
Formal · Original
A few years ago, some silly guys stole a keyboard and an antiquated flag from a site. What do you think about the reaction of the administrator? It's obvious, he used all he could to return the flag and the keyboard. Whole country were searching for an entire month and many hypotheses had been proposed by funny people. After a few years, another robbery happened. This time it was very complex, organized and supported by a big country. The robbers started their plan many years ago when we were limiting and rationing our site's capacity. Finally robbers succeeded to stole a #cf_span(class=[tex-font-style-underline], body=["dream"]) from the site! This time the admin was surprised. After exchanging a few ineffective emails the poor stolen dream was forgotten and the admin said: #cf_span(class=[tex-font-style-underline], body=["Instead of off topic discussions just suggest how you can help us for next year! We are too busy!"]) and real reasons were easily forgotten. #cf_span(class=[tex-font-style-underline], body=["Finally the stolen dream remained just a dream!"]) Let's get back to the story of the stolen flag. You should try to convince an unknown person that recreating a stolen triangular flag is not a hard task. You are given area and perimeter of the flag and you have to find integer coordinates of its vertices. The single line contains two positive space-separated integers A2 and P (1 ≤ A2 ≤ 4 × 104, 1 ≤ P ≤ 104). A2 is twice the area and P is perimeter of the flag. If it's impossible to recreate the flag, output in the single line "Flag" (without quotes) Otherwise output in the first line "Dream" (without quotes). In the next three lines output the coordinates of the triangle vertices. Each line should contain two space separated integers, each in range [ - 106, 106]. ## Input The single line contains two positive space-separated integers A2 and P (1 ≤ A2 ≤ 4 × 104, 1 ≤ P ≤ 104). A2 is twice the area and P is perimeter of the flag. ## Output If it's impossible to recreate the flag, output in the single line "Flag" (without quotes) Otherwise output in the first line "Dream" (without quotes). In the next three lines output the coordinates of the triangle vertices. Each line should contain two space separated integers, each in range [ - 106, 106]. [samples]
**Definitions** Let $ A_2 \in \mathbb{Z}^+ $ be twice the area of a triangle. Let $ P \in \mathbb{Z}^+ $ be the perimeter of the triangle. **Constraints** 1. $ 1 \leq A_2 \leq 4 \times 10^4 $ 2. $ 1 \leq P \leq 10^4 $ **Objective** Find three points $ (x_1, y_1), (x_2, y_2), (x_3, y_3) \in \mathbb{Z}^2 $ with coordinates in $ [-10^6, 10^6] $ such that: - The absolute value of the cross product $ |(x_2 - x_1)(y_3 - y_1) - (x_3 - x_1)(y_2 - y_1)| = A_2 $, - The perimeter $ \sum_{i<j} \sqrt{(x_i - x_j)^2 + (y_i - y_j)^2} = P $. If no such triangle exists, output "Flag". Otherwise, output "Dream" followed by the three vertex coordinates.
API Response (JSON)
{
  "problem": {
    "name": "H. Dreams Were Important Too!",
    "description": {
      "content": "A few years ago, some silly guys stole a keyboard and an antiquated flag from a site. What do you think about the reaction of the administrator? It's obvious, he used all he could to return the flag a",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10053H"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A few years ago, some silly guys stole a keyboard and an antiquated flag from a site. What do you think about the reaction of the administrator? It's obvious, he used all he could to return the flag a...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ A_2 \\in \\mathbb{Z}^+ $ be twice the area of a triangle.  \nLet $ P \\in \\mathbb{Z}^+ $ be the perimeter of the triangle.  \n\n**Constraints**  \n1. $ 1 \\leq A_2 \\leq 4 \\times 10^4 $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments