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:用了些基础的STL做了这题。。运行结果一致。。但就是通不过。。求大神指点。。

Posted by zhjou at 2014-05-12 00:21:59 on Problem 1007
In Reply To:用了些基础的STL做了这题。。运行结果一致。。但就是通不过。。求大神指点。。 Posted by:njut1405130211 at 2014-01-18 12:21:08
> #include<iostream>
> #include<map>
> #include<string>
> #include<algorithm>
> #include<vector>
> using namespace std;
> int main()
> {
> 	int Number(string,int);
> 	bool Sort(pair<string, int>,pair<string,int>);
> 	int length, number;
> 	string str;
> 	cin >> length >> number;
> 	vector< pair<string,int> >DNA;
> 	for (int i = 0; i != number; ++i)
> 	{
> 		cin >> str;
> 		DNA.push_back(pair<string, int>(str, Number(str, number)));
> 	}
> 	sort(DNA.begin(), DNA.end(), Sort);
> 	for (vector<pair<string ,int>>::iterator p = DNA.begin(); p != DNA.end();++p)
> 	{
> 		cout << p->first << endl;
> 	}
> 	system("pause");
> 	return 0;
> }
> 
> 
> int Number(string str, int number)
> {
> 	int counter = 0;
> 	for (int i = 0; i != number - 1; ++i)
> 	{
> 		for (int j = i + 1; j != number; ++j)
> 		{
> 			if (str[i] > str[j])
> 				++counter;
> 		}
> 	}
> 	return counter;
> }
> 
> bool Sort(pair<string, int> DNA1, pair<string, int> DNA2)
> {
> 	return DNA1.second < DNA2.second;
> }

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