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 map的自动排序 代码也相当简洁 贴下代码

Posted by lkl592726028 at 2017-11-28 10:39:51 on Problem 1007
In Reply To:使用stl map的自动排序 代码也相当简洁 贴下代码 Posted by:wangmin666 at 2016-06-28 01:44:29
> #include<iostream>
> #include<string>
> #include<map>
> #include<vector>
> 
> using namespace std;
> 
> int main()
> {
> 	int m, n;
> 	cin >> n >> m;
> 	string str[100];
> 	map<vector<int>, string>map2;
> 	for (int i = 0; i < m; i++)
> 	{
> 		cin >> str[i];
> 		vector<int>vec;
> 		int count = 0;
> 		for (int j = 0; j < n; j++)
> 		{
> 			for (int k = j; k < n; k++)
> 			{
> 				if (str[i][j]>str[i][k])
> 					count++;
> 			}
> 		}
> 		vec.push_back(count);
> 		vec.push_back(i);
> 		map2[vec] = str[i];
> 		vec.clear();
> 		
> 	}
> 	map<vector<int>, string>::iterator it;
> 	for (it = map2.begin(); it != map2.end(); it++)
> 	{
> 		cout << it->second << 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