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 题解:很简单 但是没有考虑长度为一的时候哇了两发
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
return x>y;
}
const int N=;
const int mod=1e9+;
int main()
{
std::ios::sync_with_stdio(false);
char a[];
scanf("%s",a);
int len=strlen(a);
if(len==) {
cout<<"No"<<endl;
return ;
}
sort(a,a+len);
int t=,flag=;
for(int i=;i<len;i++){
if(a[i]==a[i-]) t++;
else{
if(t%==) {
flag=;
break;
}
else t=;
}
}
if(flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return ;
}