无知时诋毁原神

Luogu
IDLGP8880
Time1500ms
Memory256MB
DifficultyP3
Special JudgeO2优化
纳西妲有一个 $0\sim n-1$ 的排列 $c$。她希望你构造两个同样为 $0\sim n-1$ 的排列的 $a,b$,满足 $\forall i\in[1,n],c_i=(a_i+b_i)\bmod n$。如果纳西妲的要求无法被满足,请输出 $-1$。 ## Input 第一行,一个整数 $n$。 第二行,$n$ 个整数,表示排列 $c$。 ## Output 如果不存在满足要求的构造,输出一行 $-1$。 否则,输出两行,每行 $n$ 个整数,第一行为 $a_i$,第二行为 $b_i$。 [samples] ## Background 纳西妲很喜欢排列。 ![](https://img2.huashi6.com/images/resource/thumbnail/2022/07/28/14225_32552389084.jpg?imageMogr2/quality/100/interlace/1/thumbnail/700x) 画师 pid:72405030 ## Note ### 数据范围 - $\text{Subtask 1(30 pts)}$:$n\le 10$。 - $\text{Subtask 2(20 pts)}$:保证有解。 - $\text{Subtask 3(50 pts)}$:无特殊性质。 对于 $100\%$ 的数据,保证 $1\le n\le 10^5$,$c$ 构成一个排列。
Samples
Input #1
3
2 1 0
Output #1
2 0 1
0 1 2
Input #2
4
1 3 0 2
Output #2
-1
API Response (JSON)
{
  "problem": {
    "name": "无知时诋毁原神",
    "description": {
      "content": "纳西妲有一个 $0\\sim n-1$ 的排列 $c$。她希望你构造两个同样为 $0\\sim n-1$ 的排列的 $a,b$,满足 $\\forall i\\in[1,n],c_i=(a_i+b_i)\\bmod n$。如果纳西妲的要求无法被满足,请输出 $-1$。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1500,
      "memory_limit": 262144
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP8880"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "纳西妲有一个 $0\\sim n-1$ 的排列 $c$。她希望你构造两个同样为 $0\\sim n-1$ 的排列的 $a,b$,满足 $\\forall i\\in[1,n],c_i=(a_i+b_i)\\bmod n$。如果纳西妲的要求无法被满足,请输出 $-1$。\n\n## Input\n\n第一行,一个整数 $n$。\n\n第二行,$n$ 个整数,表示排列 $c$。\n\n## Output\n\n如果不存在满足要求的...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments