oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

construct Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

construct.html

Problem Description

You are given a permutation P of length N. Construct two sequences A and B of length N such that:

  • 1 ≤ Ai, Bi ≤ 109,
  • A is strictly increasing,
  • B is strictly decreasing,
  • the sequence defined by (APi + BPi) is strictly increasing.

It is guaranteed that there exists a solution.

Limits

Subtask 1 (14%): 1 ≤ N ≤ 3.

Subtask 2 (20%): 1 ≤ N ≤ 70.

Subtask 3 (21%): 1 ≤ N ≤ 50 000, the bound on a strictly decreasing B is removed.

Subtask 4 (22%): 1 ≤ N ≤ 50 000, |Ai|, |Bi| ≤ 1018.

Subtask 5 (23%): 1 ≤ N ≤ 50 000.

Subtask 6 (0%): Sample Testcases.

Input

The first line of input will contain one integer, N.

The second line of input will contain N integers, representing the permutation P.

Output

The first line of output should contain N integers, the sequence A.

The second line of output should contain N integers, the sequence B.

If there are multiple solutions, all of them will be accepted.

Sample Testcase 1

Input

2
1 2

Output

1 4
5 4

Sample Testcase 2

Input

3
2 3 1

Output

5 10 100
100 10 1

Tags

Ad Hoc

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
114221s256MBMinimum
220421s256MBMinimum
321621s256MBMinimum
422621s256MBMinimum
523621s256MBMinimum
6021s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o construct -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.