044. Yoda Translator

Codeforces
IDCF10269044
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Yoda tends to confuse people with his irregular syntax. Write a program that takes in a string and switches the first half of the words with the second half. A line will contain a string. For the input, your program must print that string with the first and second half of the words switched. Assume the input will always have an even number of words. ## Input A line will contain a string. ## Output For the input, your program must print that string with the first and second half of the words switched. [samples] ## Note Assume the input will always have an even number of words.
**Definitions** Let $ S $ be a string consisting of $ 2n $ words (for some $ n \in \mathbb{Z}^+ $), separated by single spaces. Let $ W = (w_1, w_2, \dots, w_{2n}) $ be the sequence of words in $ S $, where each $ w_i $ is a non-empty substring of $ S $ delimited by spaces. **Constraints** 1. The number of words in $ S $ is even: $ |W| = 2n $ for some $ n \geq 1 $. 2. Words are separated by exactly one space. 3. No leading or trailing spaces in input. **Objective** Construct a new string $ S' $ by swapping the first half of words with the second half: $$ S' = \text{join}\left( (w_{n+1}, w_{n+2}, \dots, w_{2n}, w_1, w_2, \dots, w_n), \text{ } \right) $$ where $ \text{join}(L, \text{ }) $ concatenates the list $ L $ of words with single spaces between them.
API Response (JSON)
{
  "problem": {
    "name": "044. Yoda Translator",
    "description": {
      "content": "Yoda tends to confuse people with his irregular syntax. Write a program that takes in a string and switches the first half of the words with the second half. A line will contain a string. For the in",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269044"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Yoda tends to confuse people with his irregular syntax. Write a program that takes in a string and switches the first half of the words with the second half.\n\nA line will contain a string.\n\nFor the in...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ S $ be a string consisting of $ 2n $ words (for some $ n \\in \\mathbb{Z}^+ $), separated by single spaces.  \nLet $ W = (w_1, w_2, \\dots, w_{2n}) $ be the sequence of words in $ ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments