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 ...
随机推荐
- B/S、C/S区别
[B/S.C/S C/S (Client/Server客户端服务器) B/S (Brower/Server浏览器服务器) 区别 1.硬件环境不同: C/S 一般建立在专用的网络上, 小范围里的网络环 ...
- hdu1026
#include <stdio.h> #include <string.h> #include <queue> using namespace std; struc ...
- noip2015Day2T2-子串
题目描述 Description 有两个仅包含小写英文字母的字符串A和B.现在要从字符串A中取出k个互不重叠的非空子串,然后把这k个子串按照其在字符串A中出现的顺序依次连接起来得到一个新的字符串,请问 ...
- c# socket传输struct类型
data结构体类型 public struct datas { public string test1; public string test2; } //socket服务器端 publi ...
- CF 602C The Two Routes(dij+邻接矩阵)
( ̄▽ ̄)" #include<iostream> #include<cstdio> #include<cmath> #include<algori ...
- POJ 1230 Pass-Muraille#贪心+vector迭代器用法
(- ̄▽ ̄)-* (注意下面代码中关于iterator的用法,此代码借鉴某大牛) #include<iostream> #include<cstdio> #include< ...
- 面试中有关C++的若干问题
面试中有关C++的若干问题 By 晴天, 2014.5.16晚 什么是多态?简要说一下C++中的多态的概念. (1)定义:多态是指相同对象收到不同消息或者不同对象收到相同消息产生不同的行为. (2)C ...
- servlet规范核心类图
作为新手在写servlet时很多时候忘记类与类之间的关系,找到这张图就瞬间清晰了,这比看API要舒服很多.
- amazeui 搜索 动态
<!doctype html> <html class="no-js"> <head> <meta charset="utf-8 ...
- iOS之多线程NSOperation
目前在 iOS 和 OS X 中有两套先进的同步 API 可供我们使用:NSOperation 和 GCD .其中 GCD 是基于 C 的底层的 API ,而 NSOperation 则是 GCD 实 ...