Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

上网找了这题的测试数据,结果都对,但不知为何就是WA

Posted by ICPP at 2017-01-29 22:29:40 on Problem 2159
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator