#K11016. Secret Santa Assignment Generator
Secret Santa Assignment Generator
Secret Santa Assignment Generator
You are given a list of names representing friends participating in a Secret Santa gift exchange. Your task is to generate a valid gift exchange assignment such that each friend gives exactly one gift and receives exactly one gift, with the additional constraint that no one gives a gift to themselves.
This problem requires you to output assignments in the format "X -> Y" for each friend X, where Y is the recipient. A simple and deterministic strategy is to rotate the list of names by one position: the first friend gives a gift to the second friend, the second to the third, and the last friend gives to the first.
Note: The input will consist of multiple test cases. For each test case, you must process the list of names independently and then output the assignment for that test case. Separate the outputs for different test cases with a blank line.
The formula for the assignment if we index names from 0 to \(n-1\) is:
[ \text{assignment}[i] = \text{names}[i] \to \text{names}[(i+1) \bmod n] ]
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(T\) representing the number of test cases.
- For each test case:
- The first line contains an integer \(N\) representing the number of friends.
- The second line contains \(N\) space-separated names.
outputFormat
For each test case, output the Secret Santa assignments in \(N\) lines, each in the format "X -> Y". Separate the outputs for different test cases with a blank line. The output is written to standard output (stdout).
## sample1
3
alice bob charlie
alice -> bob
bob -> charlie
charlie -> alice
</p>