Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Excited

Posted by int64_t at 2018-04-15 10:11:46 on Problem 1007
```//In STL,sort could be customed,like this
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#define null NULL
using namespace std;
#pragma endregion
int fun(const string &str)
{
int cnt = 0;
for (int i = 0; i < str.length(); ++i)
{
for (int j = i+1; j < str.length(); ++j)
{
if (str[i] > str[j])
{
cnt++;
}
}
}
return cnt;
}
bool cmp_byValue(pair<string, int>& p1, pair<string, int>& p2)
{
return p1.second < p2.second;
}
int main(void)
{
int x, y;
scanf("%d %d", &x, &y);
vector<pair<string, int>> vc;
for (int i = 0; i < y; ++i)
{
string str;
cin >> str;
vc.push_back(pair<string, int>(str, fun(str)));
}
sort(vc.begin(), vc.end(), cmp_byValue);
for (int i = 0; i < vc.size(); ++i)
{
cout << vc[i].first << endl;
}
}
```

Followed by: