Contrast

AtCoder
IDabc178_f
Time2000ms
Memory256MB
Difficulty
Given are two sequences $A$ and $B$, both of length $N$. $A$ and $B$ are each sorted in the ascending order. Check if it is possible to reorder the terms of $B$ so that for each $i$ ($1 \leq i \leq N$) $A_i \neq B_i$ holds, and if it is possible, output any of the reorderings that achieve it. ## Constraints * $1\leq N \leq 2 \times 10^5$ * $1\leq A_i,B_i \leq N$ * $A$ and $B$ are each sorted in the ascending order. * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $A_1$ $A_2$ $\cdots$ $A_N$ $B_1$ $B_2$ $\cdots$ $B_N$ [samples]
Samples
Input #1
6
1 1 1 2 2 3
1 1 1 2 2 3
Output #1
Yes
2 2 3 1 1 1
Input #2
3
1 1 2
1 1 3
Output #2
No
Input #3
4
1 1 2 3
1 2 3 3
Output #3
Yes
3 3 1 2
API Response (JSON)
{
  "problem": {
    "name": "Contrast",
    "description": {
      "content": "Given are two sequences $A$ and $B$, both of length $N$. $A$ and $B$ are each sorted in the ascending order. Check if it is possible to reorder the terms of $B$ so that for each $i$ ($1 \\leq i \\leq N$",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc178_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given are two sequences $A$ and $B$, both of length $N$. $A$ and $B$ are each sorted in the ascending order. Check if it is possible to reorder the terms of $B$ so that for each $i$ ($1 \\leq i \\leq N$...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments