#K56052. Efficient Preparation

    ID: 30112 Type: Default 1000ms 256MiB

Efficient Preparation

Efficient Preparation

You are given a list of components represented by integers. Your task is to determine whether there exists a pair of identical components. If such a pair exists, output "YES" along with the 1-indexed positions of the first encountered pair. Otherwise, output "NO".

More formally, given an integer \( m \) and a sequence of \( m \) integers \( a_1, a_2, \dots, a_m \), find two indices \( i \) and \( j \) (with \( i < j \)) such that \( a_i = a_j \). If there are multiple possible answers, output the pair corresponding to the first duplicate you encounter in a left-to-right scan.

Note: The input is read from standard input (stdin) and the output should be written to standard output (stdout).

inputFormat

The first line contains an integer \( m \) representing the number of components. The second line contains \( m \) space-separated integers \( a_1, a_2, \dots, a_m \) representing the components.

outputFormat

If there exists a pair of identical components, output "YES" followed by the two 1-indexed positions of the components separated by spaces. Otherwise, output "NO".

Examples:

  • Input: 3\n4 6 4 → Output: YES 1 3
  • Input: 5\n2 3 4 5 6 → Output: NO
## sample
3
4 6 4
YES 1 3