poj1007——DNA Sorting
Description
greater than one letter to its right. This measure is called the number of inversions in the sequence. The sequence ``AACEDGG'' has only one inversion (E and D)---it is nearly sorted---while the sequence ``ZWQM'' has 6 inversions (it is as unsorted as can
be---exactly the reverse of sorted).
You are responsible for cataloguing a sequence of DNA strings (sequences containing only the four letters A, C, G, and T). However, you want to catalog them, not in alphabetical order, but rather in order of ``sortedness'', from ``most sorted'' to ``least sorted''.
All the strings are of the same length.
Input
Output
Sample Input
10 6
AACATGAAGG
TTTTGGCCAA
TTTGGCCAAA
GATCAGATTT
CCCGGGGGGA
ATCGATGCAT
Sample Output
CCCGGGGGGA
AACATGAAGG
GATCAGATTT
ATCGATGCAT
TTTTGGCCAA
TTTGGCCAAA
题意大概是:设一个字母序列”DAABEC“的逆序数是5,由于D比它右边的4个字母大,而E比它右边的1个字母大。序列”AACEDGG“的逆序数是1。差点儿已经排好序
如今对DNA字符串序列进行分类。然而,分类不是按字母顺序,而是按”排序“的次序,从最多已知排序到最少已知排序
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct aa
{
char s[55];
int x;
};
bool cmp(aa m,aa n)
{
return m.x<n.x;
}
int main()
{
int m,n,i,j,k;
char s[10];
cin>>n>>m;
aa a[110];
gets(s);
for(i=0; i<m; ++i)
{
gets(a[i].s);
a[i].x=0;
for(j=0; j<n; ++j)
for(k=j+1; k<n; k++)
{
if(a[i].s[j]>a[i].s[k])
a[i].x++;
}
}
sort(a,a+m,cmp);
for(i=0;i<m;++i)
cout<<a[i].s<<endl;
return 0;
}
poj1007——DNA Sorting的更多相关文章
- [POJ1007]DNA Sorting
[POJ1007]DNA Sorting 试题描述 One measure of ``unsortedness'' in a sequence is the number of pairs of en ...
- 算法:POJ1007 DNA sorting
这题比较简单,重点应该在如何减少循环次数. package practice; import java.io.BufferedInputStream; import java.util.Map; im ...
- DNA Sorting POJ - 1007
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 114211 Accepted: 45704 De ...
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- DNA Sorting 分类: POJ 2015-06-23 20:24 9人阅读 评论(0) 收藏
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 88690 Accepted: 35644 Descrip ...
- poj 1007 (nyoj 160) DNA Sorting
点击打开链接 DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 75164 Accepted: 30 ...
- [POJ] #1007# DNA Sorting : 桶排序
一. 题目 DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 95052 Accepted: 382 ...
- poj 1007 DNA Sorting
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 95437 Accepted: 38399 Des ...
- DNA Sorting(排序)
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) DNA Sorting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
随机推荐
- CISP/CISA 每日一题 四
CISA 每日一题(答) 连续在线审计技术: 1.系统控制审计检查文件和内嵌审计模型(SCARF/EAM):非常复杂,适用于正常处理不能被中断:通过在组织的主机应用系统中内嵌经特别编写的审计软件,使审 ...
- Android抖动的EditText
Java代码:启动动画 Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake); findViewById(R.id.pw ...
- js进阶 14-7 jquery的ajax部分为什么需要对表单进行序列化
js进阶 14-7 jquery的ajax部分为什么需要对表单进行序列化 一.总结 一句话总结:如果用ajax传递表单的数据,如果不进行表单的序列化,要一个参数一个参数的写,太麻烦,序列化的话,一句代 ...
- C# for 和 foreach的执行效率
for和foreach哪个执行效率快,相信很多人都会说当然是foreach快啊,在我实验之前我也是这么认为的,直到今天.费话不多说,下面是测试的结果,区分Debug和Release,数据采用int[] ...
- OpenCV func
cvLoadImage("lena.jpg", CV_LOAD_IMAGE_COLOR); //CV_LOAD_IMAGE_GRAYSCALE //0
- 洛谷 P1510 精卫填海
洛谷 P1510 精卫填海 题目描述 [版权说明] 本题为改编题. [问题描述] 发鸠之山,其上多柘木.有鸟焉,其状如乌,文首,白喙,赤足,名曰精卫,其名自詨.是炎帝之少女,名曰女娃.女娃游于东海,溺 ...
- nginx+tomcat 架构 HttpServletRequest.getScheme()获取正确的协议
http://blog.csdn.net/ofofw/article/details/46791447
- hdu5384 AC自己主动机模板题,统计模式串在给定串中出现的个数
http://acm.hdu.edu.cn/showproblem.php?pid=5384 Problem Description Danganronpa is a video game franc ...
- Oracle自定义类型在C#中调用示例
1.C#代码: 1)using Oracle.DataAccess.Types; using System; using System.Collections.Generic; using Syste ...
- 百度2019校招Web前端工程师笔试卷(9月14日)
8月27日晚,在实习公司加班.当时正在调试页面,偶然打开百度首页console,发现彩蛋,于是投了简历. 9月14日晚,七点-九点,在公司笔试. 笔试题型(有出入): 一.单选20道 1.难度不难,考 ...