K. Katastrophic sort

Codeforces
IDCF10270K
Time2000ms
Memory512MB
Difficulty
English · Original
Formal · Original
Some students at the UNAL are learning how the computer works. So the great teacher is talking about how the files are sorted by name. Do you know how that works?. Well, they are ordered by the well known Katastrophic sort!. Let's define Katastrophic sort: is an ordering of strings in lexicographical order, except that numbers are treated atomically, i.e., as if they were a single character. Let's see an example If we sort strings *z11* and *z2* by lexicographical sorting we get: But if we sort them by Katastrophic sorting we get: Since both start by *"z"* the order is defined by the order of the numeric part. And as humans, we know that *2* is less than *11*. In order to test your understanding, the teacher gives you two strings. You need to output which one is less than the other. You are given 2 lines. In each line one of the strings to compare. The length of each string is at most $10^5$. Each string will consist of a non-empty english lowercase alphabetic part followed with a non-empty numeric part It is guaranteed that the numeric parts in the strings are integers and won't have leading zeroes. It is guaranteed that the alphabetic part has the same length in both strings. Print *<* if the first string is less than the second according to the Katastrophic sort. *>* if the first string is greater than second according to the Katastrophic sort and *=* otherwise. ## Input You are given 2 lines. In each line one of the strings to compare. The length of each string is at most $10^5$.Each string will consist of a non-empty english lowercase alphabetic part followed with a non-empty numeric partIt is guaranteed that the numeric parts in the strings are integers and won't have leading zeroes.It is guaranteed that the alphabetic part has the same length in both strings. ## Output Print *<* if the first string is less than the second according to the Katastrophic sort. *>* if the first string is greater than second according to the Katastrophic sort and *=* otherwise. [samples]
**Definitions** Let $ s_1, s_2 $ be two strings, each consisting of a non-empty lowercase alphabetic prefix $ \alpha $ followed by a non-empty numeric suffix $ n $, with $ \alpha $ of identical length in both strings. Let $ s_i = \alpha_i \cdot d_i $, where: - $ \alpha_i \in \{a, b, \dots, z\}^+ $ is the alphabetic part, - $ d_i \in \mathbb{Z}^+ $ is the numeric part (given as a digit string without leading zeros). **Constraints** 1. $ |s_1|, |s_2| \leq 10^5 $ 2. $ |\alpha_1| = |\alpha_2| $ 3. $ d_1, d_2 $ are positive integers with no leading zeros. **Objective** Compare $ s_1 $ and $ s_2 $ under **Katastrophic sort**: - If $ \alpha_1 \neq \alpha_2 $, use standard lexicographical order on $ \alpha_1, \alpha_2 $. - If $ \alpha_1 = \alpha_2 $, compare $ d_1 $ and $ d_2 $ as integers. Output: - $ <$ if $ s_1 < s_2 $, - $ > $ if $ s_1 > s_2 $, - $ = $ if $ s_1 = s_2 $.
API Response (JSON)
{
  "problem": {
    "name": "K. Katastrophic sort",
    "description": {
      "content": "Some students at the UNAL are learning how the computer works. So the great teacher is talking about how the files are sorted by name. Do you know how that works?. Well, they are ordered by the well k",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10270K"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Some students at the UNAL are learning how the computer works. So the great teacher is talking about how the files are sorted by name. Do you know how that works?. Well, they are ordered by the well k...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s_1, s_2 $ be two strings, each consisting of a non-empty lowercase alphabetic prefix $ \\alpha $ followed by a non-empty numeric suffix $ n $, with $ \\alpha $ of identical leng...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments