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

Re:为什么问题WA……

Posted by Seany at 2003-08-02 20:57:52 on Problem 1002
In Reply To:为什么问题WA…… Posted by:bighead8116 at 2003-07-31 14:32:09
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

char ch[]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9','9'};

string ReadOne()
{
	string s;
	cin>>s;
	for(unsigned int i=0;i<s.length();i++)
	{
		if(isalpha(s[i]))
		{
			s[i]=ch[s[i]-'A'];
			continue;
		}
		if(s[i]=='-')
		{
			s.erase(s.begin()+i);
			i--;
			continue;
		}
	}
	return s;
}
void Output(string s)
{
	s.insert(s.begin()+3,1,'-');
	cout<<s;
}
vector<string> vec;
map<string,int> dic;
void Proc()
{
	vec.clear();
	dic.clear();
	int n;
	for(cin>>n;n;n--)
	{
		string s=ReadOne();
		if(dic.count(s))
		{
			dic[s]++;
		}
		else
		{
			dic[s]=1;
			vec.push_back(s);
		}
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++)
	{
		if(dic[vec[i]]>1)
		{
			Output(vec[i]);
			cout<<" "<<dic[vec[i]]<<endl;
		}
	}
}
int main(int argc, char* argv[])
{
	Proc();
	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