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 |
1A留念#include <map> #include <string> #include <iostream> #include <vector> #include <algorithm> using namespace std; map<string, int> m; int cal(string const &s) { int ans = 0; int a = 0, c = 0, g = 0, t = 0; for (int i = 0; i < s.size(); ++i) { switch (s[i]) { case 'A': { ++a; ans += (c + g + t); break; } case 'C': { ++c; ans += (g + t); break; } case 'G': { ++g; ans += t; break; } case 'T': { ++t; break; } default: break; } } return ans; } bool cmp(string const & s1, string const & s2) { return m[s1] < m[s2]; } int main() { #ifdef DEBUG freopen("C:\\Users\\admin\\Desktop\\编程\\in.txt", "r", stdin); #endif int len, n; cin >> len >> n; vector<string> vs(n); for (int i = 0; i < n; ++i) { cin >> vs[i]; m[vs[i]] = cal(vs[i]); } sort(vs.begin(), vs.end(), cmp); for (int i = 0; i < n; ++i) { cout << vs[i] << endl; } #ifdef DEBUG freopen("con", "r", stdin); system("pause"); #endif // DEBUG return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator