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

注意:用C++比G++快的多 using STL

Posted by lizongti at 2010-09-29 14:32:59 on Problem 1002 and last updated at 2010-09-29 15:28:29
代码效率不高 可以AC 写起来还简单 没思考太多东西吧 
#include <map>
#include <iterator>
#include <iostream>
#include <string>
using namespace std;
string StandardForm(string OneCode);
int main()
{
	int num;
	bool ExistDulp=false;
	string OneCode,StandardCode;
	cin>>num;
	map<string, int> TeleNumber;
	map<string, int>::iterator OneTeleNumber;
	while(num--)
	{
		cin>>OneCode;
		StandardCode=StandardForm(OneCode);
		OneTeleNumber=TeleNumber.find(StandardCode);
		if(OneTeleNumber==TeleNumber.end())
		{
		     TeleNumber.insert(pair<string,int>(StandardCode,1));
		}
		else
		{
		     (OneTeleNumber->second)++;
		}
	}
	for(OneTeleNumber=TeleNumber.begin(); OneTeleNumber!=TeleNumber.end();OneTeleNumber++) 
	{
		if(OneTeleNumber->second!=1)
		{
			cout<<OneTeleNumber->first<<" "<<OneTeleNumber->second<<endl;
			ExistDulp=true;		
		}
	}
	if(!ExistDulp)
	{
		cout<<"No duplicates."<<endl;
	}
	return 0;
}
string StandardForm(string OneCode)
{
	for(int i=0;i<OneCode.length();i++)
	{
		if(OneCode[i]=='A'||OneCode[i]=='B'||OneCode[i]=='C')
			OneCode[i]='2';
		else if(OneCode[i]=='D'||OneCode[i]=='E'||OneCode[i]=='F')
			OneCode[i]='3';
		else if(OneCode[i]=='G'||OneCode[i]=='H'||OneCode[i]=='I')
			OneCode[i]='4';
		else if(OneCode[i]=='J'||OneCode[i]=='K'||OneCode[i]=='L')
			OneCode[i]='5';
		else if(OneCode[i]=='M'||OneCode[i]=='N'||OneCode[i]=='O')
			OneCode[i]='6';
		else if(OneCode[i]=='P'||OneCode[i]=='R'||OneCode[i]=='S')
			OneCode[i]='7';
		else if(OneCode[i]=='T'||OneCode[i]=='U'||OneCode[i]=='V')
			OneCode[i]='8';
		else if(OneCode[i]=='W'||OneCode[i]=='X'||OneCode[i]=='Y')
			OneCode[i]='9';
		else if(OneCode[i]=='-')
		{
			OneCode.erase(i,1);
			i--;
		}
	}
	OneCode.insert(3,"-");
	return OneCode;
}

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