6. Kitchen Plates

Codeforces
IDCF102156
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You are given 5 different sizes of kitchen plates. Each plate is marked with a letter *A, B, C, D, or E*. You are given $5$ statements comparing two different plates, you need to rearrange the plates from smallest size to biggest size. For example: the sizes of these plates The input consist of $5$ lines. In each line there will be $3$ characters, the first and last character will be either *A, B, C, D, or E* and the middle character will be either *>* or *<* describing the comparison between two plates sizes. No two plates will be equal. The output consist of 5 characters, the sorted order of balls from smallest to biggest plate. Otherwise, if the statements are contradicting print *impossible*. If there are multiple answers, print any of them ## Input The input consist of $5$ lines. In each line there will be $3$ characters, the first and last character will be either *A, B, C, D, or E* and the middle character will be either *>* or *<* describing the comparison between two plates sizes. No two plates will be equal. ## Output The output consist of 5 characters, the sorted order of balls from smallest to biggest plate. Otherwise, if the statements are contradicting print *impossible*. If there are multiple answers, print any of them [samples]
**Definitions** Let $ P = \{A, B, C, D, E\} $ be the set of plate labels. Let $ S \subseteq P \times \{<, >\} \times P $ be a set of 5 strict binary comparison statements, where each statement is of the form $ (X, \text{op}, Y) $ with $ X \ne Y $ and $ \text{op} \in \{<, >\} $, meaning $ X < Y $ or $ X > Y $. **Constraints** 1. Each statement in $ S $ compares two distinct plates. 2. No two plates are equal (all sizes are distinct). 3. $ |S| = 5 $. **Objective** Find a total order $ \pi = (p_1, p_2, p_3, p_4, p_5) $ of $ P $ such that for every statement $ (X, \text{op}, Y) \in S $: - If $ \text{op} = < $, then $ \pi^{-1}(X) < \pi^{-1}(Y) $, - If $ \text{op} = > $, then $ \pi^{-1}(X) > \pi^{-1}(Y) $. If no such total order exists, output *impossible*. If multiple exist, output any one.
API Response (JSON)
{
  "problem": {
    "name": "6. Kitchen Plates",
    "description": {
      "content": "You are given 5 different sizes of kitchen plates. Each plate is marked with a letter *A, B, C, D, or E*. You are given $5$ statements comparing two different plates, you need to rearrange the plates ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF102156"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given 5 different sizes of kitchen plates. Each plate is marked with a letter *A, B, C, D, or E*. You are given $5$ statements comparing two different plates, you need to rearrange the plates ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ P = \\{A, B, C, D, E\\} $ be the set of plate labels.  \nLet $ S \\subseteq P \\times \\{<, >\\} \\times P $ be a set of 5 strict binary comparison statements, where each statement is ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments