Winter D3 A Find the Lost Sock

Source: Internet
Author: User

Alice bought a lot of pairs of socks yesterday. But when she was went home, she found that she had lost one of the them. Each sock has a name which contains exactly 7 charaters.

Alice wants to know which sock she had lost. Maybe can help her.

Input

There is multiple cases. The first line containing a integer n (1 <= n <= 1000000) indicates that Alice bought N Pairs of socks. For the following to1 lines, each line was a string with 7 charaters indicating the name of the socks that Alice Took back.

Output

The name of the lost sock.

Sample Input
2aabcdefbzyxwvubzyxwvu4aqwertyeas FGHAQWERTYEASDFGHEASDFGHAQWERTYAQWERTY20X0ABCD0ABCDEF0X0ABCD
Sample Output
Aabcdefeas Fgh0abcdef
Hint

Because of HUGE input, scanf is recommended.

Method 1:

#include <cstdio> #include <cmath> #include <cstring> #include <stdlib.h>char a[2000005][8];// Note: If you use Qsort to sort a two-dimensional array  , you should use strcmp if  it is not-int cmp (const void *a,const void *b) {    return strcmp ((char*) A, (char*) b);} int main () {    int i,j,k;    int n;    Fast row, detects adjacent strings while    (scanf ("%d", &n)!=-1)    {        getchar ();        for (i=0;i<2*n-1;i++)        gets (A[i]);        Qsort (A,2*n-1,sizeof (a[0]), CMP);        if (strcmp (a[0],a[1])!=0) {printf ("%s\n", a[0]); continue;}        for (i=0;i<2*n-1;i+=2)        if (strcmp (a[i],a[i+1])!=0) {printf ("%s\n", A[i]);    

Method 2: Each string is 7 characters, counting each character of each string with an array if the last character has an odd number of characters, the character is output (get)

Winter D3 A Find the Lost Sock

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.