poj 1007 DNA Sorting
来源:互联网 发布:阿里云按量计费 编辑:程序博客网 时间:2024/06/04 19:47
中文翻译在这里:
http://blog.sina.com.cn/s/blog_61eccf0e0100epql.html
为了理解这道题目,花了相当大的功夫。其实这道题很简单,只是题意理解起来难度不低。
对于"ZWQM"这个字符串来说,逆序列为:ZW,ZQ,ZM,WQ,WM,QM;逆序数为6
所以对于本题的字符串来说:,遍历每一位,在当前位上往后看,有一个小于该位置字母的,就要对这个字符串的逆序数加1.
由好到坏即逆序数由小到大。
#include <iostream>#include <algorithm>#include <vector>#include <string>using namespace std;struct DNA {string s;int value;};bool cmp(DNA a, DNA b){return a.value < b.value;}int main(){int n, m;while (cin >> m >> n){vector<DNA> DNF;DNA cunchu;for (int i = 0; i != n; i++){cin >> cunchu.s;cunchu.value = 0;for (int j = 0; j != m; j++){for (int k = j + 1; k != m; k++){if (cunchu.s[j]>cunchu.s[k])cunchu.value++;}}DNF.push_back(cunchu);}sort(DNF.begin(),DNF.end(),cmp);for (vector<DNA>::iterator it = DNF.begin(); it != DNF.end(); it++)cout << it->s << endl;}return 0;}
0 0
- POJ 1007 DNA Sorting
- poj 1007 DNA Sorting
- POJ 1007 DNA Sorting
- POJ-1007 DNA Sorting
- 【POJ】1007 DNA Sorting
- POJ-1007:DNA Sorting
- poj 1007 DNA Sorting
- POJ 1007 DNA Sorting
- POJ 1007 DNA Sorting
- poj 1007 DNA Sorting
- POJ 1007 DNA Sorting
- 【POJ】1007 DNA Sorting
- poj 1007 DNA sorting
- POJ 1007 DNA Sorting
- poj 1007 DNA Sorting
- [POJ][1007]DNA Sorting
- POJ 1007 DNA Sorting
- poj 1007 DNA sorting
- Redis和Memcached的区别
- Java状态机
- OpenCV学习笔记(四十六)——FAST特征点检测features2D OpenCV学习笔记(四十七)——VideoWriter生成视频流highgui OpenCV学习笔记(四十八)——PCA算
- Solr索引pdf.txt.word等文件
- 利用Visual Studio 自带工具查询lib 或者 dll 文件是32位还是64位
- poj 1007 DNA Sorting
- Question1
- python爬虫--BeautifulSoup的简单用法
- 区分JS中的undefined,null,"",0和false
- C++ STL基本容器的使用
- leetcode101题 题解 翻译 C语言版 Python版
- linux 的 socket例子
- softirq, tasklet和workqueue的区别
- ToDo-List-><学习Python>