ACM looks for two gay guys in many couples ' stacks

Source: Internet
Author: User

Title Description
When Wodex was running in the He village to live down, He fainted by fumes. Fortunately, a mysterious man saved him ...

Ten years later, he learned some skills from the mysterious man and has knowed who was personal enemy, just named Zero. So, he embarked on a journey of revenge.
But before it, the mysterious mans wanted to test him.
Problem comes. The mysterious man prapared a maze where hided a brave sword. To get it, Wodex came in the maze.

There were many keys in the maze, each key had a number, only the keys can open the door to get brave sword. But there existed many keys ' number were the same in pairs, if the number of Keya is the same as KeyB, these the keys won ' t be the solution to the door. So, there would is left only the last of the different numbers of keys.

Can Wodex to find out these?

input
Input until EOF.
First line would contain an even integer n (n < 100,000) means the number of whole keys.
And next line would contain N integers. Each integer means the number of each key.

Output
What is they? Output the number of their keys from small to large.

Sample Input
8
1 1 2 2 2 3 3 4
8
1 1 2 2 3 3 4 5

Sample Output
2 4
4 5


Analysis

Do you think of the problem of the big battle of chopsticks?
The meaning of the problem is that there are many chopsticks, except one, the other is the equivalent of a long appearance.
Direct XOR, all the same number will be offset (in the XOR operation, the same position value equals the result is 0, that is, all pairs appear will eventually become 0), the final result is naturally the number of the single.

Then, let's look at the question.
It means that there are a lot of couples, each couple holding the same brand, and then in this group, there are two people are the base, they hold the brand is not the same, please find out the two people, and from small to large output their brand.
Then the problem is slightly more complicated, from a single to two single.

If there are two different numbers, we can divide him into two segments, each of which is a A-B. Here to explain the convenience, give 10 numbers, respectively, a,a,b,b,c,c,d,d,e,f;

Now we know that as long as the paragraphs A and B can meet the above (1) The situation, that is, two different numbers (E,f respectively in A, b) respectively in different paragraphs, the other pairs appear in the same paragraph, you can imitate (1) to obtain the results. Give an example a (a,a,b,b,e); B (C,C,D,D,F);

Do you find it hard to score? How can the above form be separated into a A, b? Don't worry, notice, I said above is the other number in pairs appear, not necessarily to half points, also can be a (a,a,b,b,c,c,d,d,e); B (f); or a (a,a,b,b,c,c,e); B (d,d,f); Is it a little bit of a clue? No? Don't worry, look down, it's almost done.

Let's start by thinking about how to divide e,f. First, they are not equal, so the value of the e^f must not be 0, that is, the value of E^f is converted to 2, and at least one 1 must appear. OK, we'll look from right to left for the first time 1 of the position, all the numbers, this position is 1 in a, is 0 of the put in B. OK, fully meet our requirements for the AB segment, and then separate from a a, or find e,f is not a problem!

ACM looks for two gay guys in many couples ' stacks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.