F. Game

Codeforces
IDCF10247F
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Alice and Bob are playing _Luzhanqi_. Each of them has a _permutation_ of the following $24$ pieces: The first line contains one integer $T$ denoting the number of test cases ($1 <= T <= 100$). Each of the next $T$ lines contains $24$ integers denoting Alice's permutation: Output one line for each test case. If Bob cannot construct the required permutation, print $-1$. Otherwise, print $24$ integers representing Bob's permutation in the same format as in the input. If there are multiple solutions, print any. Bob's permutation must contain exactly the $24$ pieces described in the statement. Note that the sample input and sample output contain wrapped lines to fit in the width of page. ## Input The first line contains one integer $T$ denoting the number of test cases ($1 <= T <= 100$).Each of the next $T$ lines contains $24$ integers denoting Alice's permutation: $40$ represents Field Marshal $39$ represents General $38$ represents Major Generals $37$ represents Brigadier Generals $36$ represents Colonels $35$ represents Majors $34$ represents Captains $33$ represents Lieutenants $32$ represents Engineers $31$ represents Landmines $30$ represents Bombs It is guaranteed that all permutations are chosen uniformly at random and contains exactly the $24$ pieces described in the statement. ## Output Output one line for each test case.If Bob cannot construct the required permutation, print $-1$.Otherwise, print $24$ integers representing Bob's permutation in the same format as in the input. If there are multiple solutions, print any. Bob's permutation must contain exactly the $24$ pieces described in the statement. [samples] ## Note Note that the sample input and sample output contain wrapped lines to fit in the width of page.
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. Let $ A = (a_1, a_2, \dots, a_{24}) $ be a permutation of the multiset $ \{1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8\} $, representing Alice's pieces. **Constraints** 1. $ 1 \leq T \leq 100 $ 2. For each test case, $ A $ is a permutation of the multiset $ \{1^3, 2^3, 3^3, 4^3, 5^3, 6^3, 7^3, 8^3\} $ (each integer from 1 to 8 appears exactly three times). **Objective** For each test case, find a permutation $ B = (b_1, b_2, \dots, b_{24}) $ of the same multiset such that $ b_i \neq a_i $ for all $ i \in \{1, \dots, 24\} $. If no such $ B $ exists, output $ -1 $. Otherwise, output any valid $ B $.
API Response (JSON)
{
  "problem": {
    "name": "F. Game",
    "description": {
      "content": "Alice and Bob are playing _Luzhanqi_. Each of them has a _permutation_ of the following $24$ pieces:  The first line contains one integer $T$ denoting the number of test cases ($1 <= T <= 100$). Eac",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10247F"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Alice and Bob are playing _Luzhanqi_. Each of them has a _permutation_ of the following $24$ pieces: \n\nThe first line contains one integer $T$ denoting the number of test cases ($1 <= T <= 100$).\n\nEac...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nLet $ A = (a_1, a_2, \\dots, a_{24}) $ be a permutation of the multiset $ \\{1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8\\} $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments