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 dreamvtkd at 2009-04-23 21:00:42 on Problem 1002
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

struct num
{
	char a[8];
};

num input[100000]; 

bool cmp(const num &c,const num &d )
{
	for (int i = 0; i < 7; ++i)
	{
		if (c.a[i] != d.a[i])
		{
			return c.a[i] < d.a[i]; 
		}
	}
	return 0; 
}

int main()
{
 //	freopen("in.txt","r",stdin); 

	int n = 0; 
	string temp = ""; 
	int i,j,f; 
	cin >> n; 

	for (i = 0; i < n; ++i)
	{
			
			cin >> temp; 
			int pa = 0;				//point to a[]; 
			for (j = 0; j < temp.length(); ++j)
			{
				if (temp[j] >= '0' && temp[j] <= '9')
				{
					input[i].a[pa] = temp[j]; 
					++pa; 
					
					continue; 
				}

				else 
					if (temp[j] == 'A' || temp[j] == 'B' || temp[j] == 'C')
					{
					input[i].a[pa] = '2'; 
					++pa;
					continue; 
					}
				else
					if (temp[j] == 'D' || temp[j] == 'E' || temp[j] == 'F')
					{
						input[i].a[pa] = '3'; 
						++pa;
						continue; 

					}
					else
						if (temp[j] == 'G' || temp[j] == 'H' || temp[j] == 'I')
						{
							input[i].a[pa] = '4'; 
							++pa;
							continue; 
						}
						else
							if (temp[j] == 'J' || temp[j] == 'K' || temp[j] == 'L')
							{
								input[i].a[pa] = '5'; 
								++pa;
								continue; 
							}
							else
								if (temp[j] == 'M' || temp[j] == 'N' || temp[j] == 'O')
								{
									input[i].a[pa] = '6'; 
									++pa;
									continue; 
								}
								else
									if (temp[j] == 'P' || temp[j] == 'R' || temp[j] == 'S')
									{
										input[i].a[pa] = '7'; 
										++pa;
										continue; 
									}
									else
										if (temp[j] == 'T' || temp[j] == 'U' || temp[j] == 'V')
										{
											input[i].a[pa] = '8'; 
											++pa;
											continue; 
										}
										else
											if (temp[j] == 'W' || temp[j] == 'X' || temp[j] == 'Y')
											{
												input[i].a[pa] = '9'; 
												++pa;
												continue; 
											}
												else
												{
													continue; 
												}
				}


			}
//	input the data 
	
	
	sort(input,input+n,cmp);					//排序




	int flag = 0; 

	for (i = 0,f = 1; i < n,f < n; )
	{

		if (strcmp(input[f].a,input[i].a) == 0)
		{
			
			flag = 1;


			if (f == n-1 && f!=i)
			{
				for (j = 0; j < 7; ++j)
				{
					cout << input[i].a[j]; 
					
					if (j == 2)
					{
						cout << '-'; 
					}
					
				}
				
				
				cout << " " << f+1-i << endl;
				break;
				
			}
				++f; 
		}



		else
			if ( (f-i)>1)
			{
				
				for (j = 0; j < 7; ++j)
				{
					cout << input[i].a[j]; 
					if (j == 2)
					{
						cout << "-"; 
					}
					
				}
					
					
					cout << " " << f-i << endl;
				
				i = f; 
			}
			else
			{
				i = f; 
			}
				
		
	}
	if (flag == 0 || n == 1)
	{
		cout << "No duplicates." << 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