| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
上网找了这题的测试数据,结果都对,但不知为何就是WA#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
int main()
{
char str_one[100] = { 0 };
char str_two[100] = { 0 };
vector<int> count_one;
vector<int> count_two;
cin >> str_one >> str_two;
int len = strlen(str_one);
if (len != strlen(str_two))
{
cout << "NO" << endl;
return 0;
}
sort(str_one, str_one + len);
sort(str_two, str_two + len);
int i = 0;
int j = 0;
for (int count = 0; i < len; i++, count++)
{
count_one.push_back(1);
while (str_one[i] == str_one[i + 1])
{
i++;
count_one[count] += 1;
}
}
for (int count = 0; j < len; j++, count++)
{
count_two.push_back(1);
while (str_two[j] == str_two[j + 1])
{
j++;
count_two[count] += 1;
}
}
sort(count_one.begin(), count_one.end());
sort(count_two.begin(), count_two.end());
int size = count_one.size();
if (size != count_two.size())
{
cout << "NO";
return 0;
}
for (i = 0; i < size; i++)
{
if (count_one[i] != count_two[i])
{
cout << "NO";
return 0;
}
}
cout << "YES";
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator