HDU1379:DNA Sorting
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.
This problem contains multiple test cases!
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
10 6
AACATGAAGG
TTTTGGCCAA
TTTGGCCAAA
GATCAGATTT
CCCGGGGGGA
ATCGATGCAT
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std; struct node
{
char a[];
int num;
} DNA[]; bool cmp(const node &a,const node &b)
{
if(a.num<=b.num)
return true;
else return false;
} int main()
{
int t,len,n,c;
cin>>t;
while(t--)
{
cin>>len>>n;
for(int i=;i<n;i++)
cin>>DNA[i].a;
for(int i=;i<n;i++)
{
DNA[i].num=;
c=;
for(int j=;j<len;j++)
{
for(int m=j+;m<len;m++)
{
if(DNA[i].a[j]>DNA[i].a[m])
c++;
}
}
DNA[i].num=c;
}
sort(DNA,DNA+n,cmp);
for(int i=;i<n;i++)
cout<<DNA[i].a<<endl;
}
return ;
}
HDU1379:DNA Sorting的更多相关文章
- 算法:POJ1007 DNA sorting
这题比较简单,重点应该在如何减少循环次数. package practice; import java.io.BufferedInputStream; import java.util.Map; im ...
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- [POJ1007]DNA Sorting
[POJ1007]DNA Sorting 试题描述 One measure of ``unsortedness'' in a sequence is the number of pairs of en ...
- 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: ...
- [POJ 1007] DNA Sorting C++解题
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 77786 Accepted: 31201 ...
随机推荐
- 【c++】size_t 和 size_type的区别
为了使自己的程序有很好的移植性,c++程序员应该尽量使用size_t和size_type而不是int, unsigned 1. size_t是全局定义的类型:size_type是STL类中定义的类型属 ...
- Mac软件记录
前端: Brackets,sourceTree,dreamweaver,ps,ai,softmatic Weblayers. phpStorm,pyCharm,IDEA,eaclipse,XCODE, ...
- Python 第一课笔记
1.Hello World程序的两种方法 在windows下执行 1.编辑器里输入,不用编译 print("Hello World!") 直接就可以运行 2.可以 ...
- js跨域请求获得数据
很多时候我们想访问其它站点下的数据怎么办? 由于javascript语言安全限制即同源策略造成的. 在使用ajax请求访问其他服务器的数据,此时客户端会出现跨域问题. 在js中,我们直接用XMLHtt ...
- POJ 3740 Easy Finding
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using ...
- linux jdk环境变量
export JAVA_HOME=/usr/share/jdk8 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/ ...
- 关于js优化和css优化
css优化: 1.css代码的压缩. 2.css文件的合并. 3.不滥用float,因为float在渲染时计算量比较大,所以尽量减少使用float. 4.避免在html标签中写style属性. js优 ...
- strstr() strpos() 获取db报错,判断报错中是否包含字符串,判断错误类型
model中直接获取添加公司的错误.(公司名称不能重复) $enterprise_id = $this->add($enterprisedata ); $err = $this->getD ...
- 1、第一个SpringMVC程序
1.创建如下项目结构 2.在src下的com.springmvc下创建User.java package com.springmvc; public class User { private Stri ...
- Django的用户认证
Django中用户登陆的实例: 逻辑流程 1.客户端发起请求,根据url规则会首先转至index函数, 2.在index函数上添加一个装饰器('@login_required',django自带).加 ...