String pairs of ACM (implemented in C ++)

Source: Internet
Author: User

 

Paired string

Description

Some strings are called pairs if they meet the following requirements:

A. All characters appear even in the string

B. Each pair of identical characters does not contain any odd number of characters.

Now, you can check whether these strings are correct strings.

Input:

The first line is an integer K, indicating the number of test cases, and the next line is a test case. Each behavior is a string (up to 1000 characters ).

Output:

Each row outputs the results of a test case. If Yes, Yes is output; otherwise, No is output.

Sample Input

2

AAbbAaaabbcc

Abcdefghijklmn

 

Sample Output

Yes

No

# Include <iostream>

Using namespace std;

Char str [1000];

Int cNum [100];

 

Int main ()

{

Int cas;

Cin> cas;

While (cas --)

{

Scanf ("% s", str );

Int k = strlen (str );

Memset (cNum, 0, sizeof (cNum ));

Int I = 0;

Int sum = 0;

If (k % 2)

{

Cout <"No" <endl;

Continue;

}

While (I <k)

{

If (cNum [str [I] = 0)

{

CNum [str [I] = I + 1;

}

Else

{

If (I-cNum [str [I]) % 2 = 0) {sum + = 2; cNum [str [I] = 0 ;}

}

I ++;

}

If (sum = k)

Cout <"Yes" <endl;

Else

Cout <"No" <endl;

}

Return 0;

}

 

From my dream and my dream ~~~

Climb to the top of the hill ~~~

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.