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:只能说你 C++没学得太好。

Posted by zrO_Orz at 2008-10-18 20:30:02 on Problem 1007
In Reply To:搞不懂为什么要改成51 Posted by:springtty at 2008-10-18 20:23:07
> 改成51之前都是“Output Limit Exceeded”,改成51就AC了。
> 
> #include <iostream>
> #include <algorithm>
> #include <vector>
> using namespace std;
> 
> typedef pair<char*,int>  node;
> typedef unsigned int UINT;
> 
> inline UINT cacu(const char str[],int len)
> {
> 	UINT sum = 0;
> 	
> 	for(int i = 0; i < len - 1; ++i)
> 		for(int j = i + 1; j < len; ++j)
> 		{
> 			if( str[i] > str[j])	sum++;		
> 		}
> 		
> 	return sum;	
> }
> 
> bool measure_compare(const node &a,const node &b)
> {
> 	return a.second < b.second;	
> }
> 
> int main(int argc, char *argv[])
> {
> 	int n,m;
> 	UINT sum;
> 	char str[100][51] = {0}; //题目明明说最大为50
> 	
> 	vector<node>vec_str;
> 		
> 	cin>>n>>m;
> 	
> 	for(int i = 0;i < m; ++i)
> 	{
> 		cin>>str[i];
> 		sum = cacu(str[i],n);
> 		vec_str.push_back( make_pair(str[i],sum) );			
> 	}
> 	
> 	stable_sort(vec_str.begin(),vec_str.end(), measure_compare);
> 	
> 	for(int i = 0; i < vec_str.size(); ++i)
> 	{
> 		cout<<vec_str[i].first<<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