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

求大牛指点1002为什么一直WA,论坛上的测试数据都试过了还是不行

Posted by stars570 at 2012-07-15 01:20:58 on Problem 1002
#include<iostream>
#include<string>
using namespace std;

int main()
{
	int num=0,count,l;
	string p[2][300];
	string tmp="";
	bool judge=false;
	cin>>num;
	for(int i=0;i<num;i++)
	{
		cin>>tmp;
		char t[9]="";
		l=0;
		for(unsigned int j=0;j<tmp.size();j++)
		{
			char c=tmp[j];
			if(c!='-'&&c!='Q'&&c!='Z'&&l<8)
			{
				if(l==3)
				{t[l]='-';l++;}
				if(c>='0'&&c<='9')
					t[l]=c;
				else if(c>='A'&&c<'Z')
				switch(c)
				{
				case 'A': case 'B':case 'C': 
					t[l]='2';
					break;
				case 'D': case 'E':case 'F':
					t[l]='3';
					break;
				case 'G': case 'H':case 'I': 
					t[l]='4';
					break;
				case 'J': case 'K':case 'L':
					t[l]='5';
					break;
				case 'M': case 'N':case 'O': 
					t[l]='6';
					break;
				case 'P': case 'R':case 'S':
					t[l]='7';
					break;
				case 'T': case 'U':case 'V': 
					t[l]='8';
					break;
				case 'W': case 'X':case 'Y':
					t[l]='9';
					break;
				default:
					l--;
			}
				l++;
			}
		}
		p[0][i]=t;
	}
	for(int i=0;i<num;i++)
	{
		int tmp=1;
		for(int j=i+1;j<num;j++)
			{
				if(p[0][i]==p[0][j]&&p[0][i].size()>0)
				{
					judge=true;
					tmp++;
					p[0][j]="";
				}
		}
		if(tmp!=1)
		{
			count=tmp;
		char c[10];
		_itoa(count,c,10);
		p[1][i]=c;
		}}
	if(judge==false)
		cout<<"No duplicates. "<<endl;
	else
		for(int i=0;i<num;i++)
		{
			if(p[0][i]!="")
				for(int j=i+1;j<num;j++)
					if(p[0][j]!=""&&p[0][i]>p[0][j])
					{tmp=p[0][i];p[0][i]=p[0][j];p[0][j]=tmp;
			         tmp=p[1][i];p[1][i]=p[1][j];p[1][j]=tmp;}
		}
		for(int i=0;i<num;i++)
			if(p[1][i]!="")
				{
					int c=atoi(p[1][i].c_str());
					cout<<p[0][i]<<' '<<c<<endl;
			}
	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