P27329 [AtCoder] Duplicate Inspection
提高
题目描述

Problem Description

A sequence of integers of length $ N $ is stored on a server. Until just recently, this sequence contained exactly one of each integer from $ 1 $ to $ N $.

However, due to a recent trouble, one of the elements in the sequence may have been replaced with another integer between $ 1 $ and $ N $. Alternatively, no replacement may have occurred.

You are given the sequence of integers $A_1,\ \ldots,\ A_N$ after the trouble. Write a program that reads this sequence and determines whether a replacement has occurred. If a replacement has occurred, report which integer was replaced by which other integer.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ A_2 $ $ : $ $ A_N $

Output Format

If no replacement has occurred, output Correct.

If a replacement has occurred, output the integer $ y $ that replaced integer $ x $, in the order $ y $ followed by $ x $, separated by a space.

Sample Input and Output

Sample Input #1

6
1
5
6
3
2
6

Sample Output #1

6 4

Sample Input #2

7
5
4
3
2
7
6
1

Sample Output #2

Correct

Notes/Hints

Constraints

  • $1\ \leqq\ N\ \leqq\ 200,000$
  • $1\ \leqq\ A_i\ \leqq\ N$
  • $A_1,\ \ldots,\ A_N$ does not contradict the situation described in the problem.

Sample Explanation 1

The original sequence should have contained exactly one of each integer from $ 1 $ to $ 6 $. However, the input sequence contains two $ 6 $s and does not contain $ 4 $. Therefore, it can be determined that $ 4 $ was replaced by $ 6 $.

Sample Explanation 2

The original sequence should have contained exactly one of each integer from $ 1 $ to $ 7 $, and the input sequence satisfies this. Therefore, it can be determined that no replacement occurred.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
6 1 5 6 3 2 6
样例输出
6 4