#C5742. Find Pair with Given Sum

    ID: 49425 Type: Default 1000ms 256MiB

Find Pair with Given Sum

Find Pair with Given Sum

You are given an array of integers and a target integer \(x\). Your task is to find a pair of distinct indices \(i\) and \(j\) such that \(a_i + a_j = x\). If such a pair exists, output the indices in the order they are found (the first valid pair); if no such pair exists, output an empty line.

The input consists of multiple test cases. For each test case, the first line contains two integers \(n\) and \(x\), where \(n\) is the number of elements in the array. The next line contains \(n\) space-separated integers representing the array elements. For each test case, if a valid pair is found, output a single line containing the two indices separated by a space; otherwise, output an empty line.

Note: Indices are zero-based.

inputFormat

The first line contains an integer \(T\), the number of test cases. Each test case is described as follows:

  • The first line of a test case contains two integers \(n\) and \(x\), where \(n\) is the number of elements in the array and \(x\) is the target sum.
  • The second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

For each test case, print a single line containing two space-separated integers denoting the indices of the two array elements that sum up to \(x\). If no valid pair exists, print an empty line.

## sample
3
4 9
2 7 11 15
3 6
3 2 4
3 10
3 7 1
0 1

1 2 0 1

</p>