AtCoder Beginner Contest 044 B - 美しい文字列 / Beautiful Strings

Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied:

  • Each lowercase letter of the English alphabet occurs even number of times in w.

You are given the string w. Determine if w is beautiful.

Constraints

  • 1≤|w|≤100
  • w consists of lowercase letters (a-z).

Input

The input is given from Standard Input in the following format:

w

Output

Print Yes if w is beautiful. Print No otherwise.


Sample Input 1

Copy
abaccaba

Sample Output 1

Copy
Yes

a occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.


Sample Input 2

Copy
hthth

Sample Output 2

Copy
No

题解:很简单 但是没有考虑长度为一的时候哇了两发
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <vector>
 6 #include <cstdlib>
 7 #include <iomanip>
 8 #include <cmath>
 9 #include <ctime>
10 #include <map>
11 #include <set>
12 #include <queue>
13 #include <stack>
14 using namespace std;
15 #define lowbit(x) (x&(-x))
16 #define max(x,y) (x>y?x:y)
17 #define min(x,y) (x<y?x:y)
18 #define MAX 100000000000000000
19 #define MOD 1000000007
20 #define pi acos(-1.0)
21 #define ei exp(1)
22 #define PI 3.141592653589793238462
23 #define INF 0x3f3f3f3f3f
24 #define mem(a) (memset(a,0,sizeof(a)))
25 typedef long long ll;
26 ll gcd(ll a,ll b){
27     return b?gcd(b,a%b):a;
28 }
29 bool cmp(int x,int y)
30 {
31     return x>y;
32 }
33 const int N=10005;
34 const int mod=1e9+7;
35 int main()
36 {
37     std::ios::sync_with_stdio(false);
38     char a[101];
39     scanf("%s",a);
40     int len=strlen(a);
41     if(len==1) {
42         cout<<"No"<<endl;
43         return 0;
44     }
45     sort(a,a+len);
46     int t=1,flag=1;
47     for(int i=1;i<len;i++){
48         if(a[i]==a[i-1]) t++;
49         else{
50             if(t%2==1) {
51                 flag=0;
52                 break;
53             }
54             else t=1;
55         }
56     }
57     if(flag) cout<<"Yes"<<endl;
58     else cout<<"No"<<endl;
59     return 0;
60 }
posted @ 2017-08-05 01:33  wydxry  阅读(581)  评论(0编辑  收藏  举报
Live2D