Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
ME TOOIn Reply To:自己测试对了但是提交是WA( `д′),求助 Posted by:zqu971223 at 2016-07-01 21:56:24 #include<iostream> #include<map> #include<string> using namespace std; int inversion(string str) { int count = 0; int len = str.length(); for (int i = 0; i < len - 1; i++) { for (int j = i+1; j < len; j++) { if (str[i] > str[j]) count++; } } return count; } int main() { int m, n; cin >> m >> n; map<int, string> M; while (n--) { string str; cin >> str; M.insert(make_pair(inversion(str), str)); } for (std::map<int, string>::iterator it = M.begin(); it != M.end(); it++) { cout << it->second << endl; } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator