DNA Sorting--hdu1379
DNA Sorting
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2203 Accepted Submission(s): 1075
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.
这个题开始就没读懂,所以也不会做,后来学长讲完后才明白啥意思;
就是比如第一行数据AACATGAAGG 首先定义sum=0, A大于它后面字符的个数为0,sum+=0,第二个同样,第三个C大于它后面字符的个数为3,sum+=3。。。以此类推!
然后按每行数字从小到大输出字符串!!!
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct as
{
char s[];
int m;
}aa[];
bool cmp(as s,as t)
{
return s.m < t.m;
}
int main()
{
int n,i,j,k,t,a,b,q;
scanf("%d",&n);
while(n--)
{
scanf("%d%d",&a,&b);
getchar();
for(k=;k<b;k++)
{ scanf("%s",aa[k].s);
{
for(t=;t<a;t++)
{
int sum=;
for(i=;i<a-;i++)
{
for(j=i+;j<a;j++)
if(aa[t].s[i]>aa[t].s[j])
sum++;
}
aa[t].m=sum;//将各组总数放在结构体中
} }
}
sort(aa, aa+b, cmp);//排序结构体
for(i=;i<b;i++)
printf("%s\n",aa[i].s);
}
return ;
}
DNA Sorting--hdu1379的更多相关文章
- 算法: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 ...
- HDU 1379:DNA Sorting
DNA Sorting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
随机推荐
- 雅思创始人Keith Taylor谈英语学习
雅思创始人Keith Taylor谈英语学习 “要学的是信息,而不是语言” 我们要学习一个国家的语言就得知道这个国家的方方面面.要学习英语就得了解英美国家的社会.经济.人文.历史等各方面的信息. 大家 ...
- FileAttributes枚举
FileAttributes枚举是一个专门用于标记硬盘上的文件属性的枚举,枚举的说明在这里:http://www.cnblogs.com/kissdodog/archive/2013/01/16/28 ...
- 【MVC4 之 ViewData ViewBag TempData】
ViewData (一个字典集合类型):传入的key必须是string类型,可以保存任意对象信息,特点:它只会存在这次的HTTP的要求中而已,并不像session可以将数据带到下一个Http要求. V ...
- GetCurrentDirectory、SetCurrentDirectory和GetModuleFileName
DWORD GetCurrentDirectory( DWORD nBufferLength, // size of directory buffer LPTSTR lpBuffer // ...
- UIScollView Touch事件
customScrollView.h #import <UIKit/UIKit.h> @interface customScrollView : UIScrollView @end cus ...
- JavaScript面向对象精要(一)
数据类型 在JavaScript中,数据类型分为两类: 原始类型:保存一些简单数据,如true.5等.JavaScript共同拥有5中原始类型: boolean:布尔.值为true或false num ...
- sqlite数据库读写在linux下的权限问题
近期在学linux,恰巧有个php项目要做.于是配置好环境打算在linux下做. 无奈站点执行后一片空白.经过调试发现是sqlite数据库的问题. 安装sqlite扩展 apt-get install ...
- 关于Oracle SQL/82标准和SQL/92标准
在ORACLE9i之前,oracle语法基础是SQL/86标准,9i及之后的版本中支持SQL/92标准.基表信息:products.purchases和product_types SQL> se ...
- kvm虚拟化之克隆篇
注意:在克隆虚拟机的时候,该虚拟机必须处于关闭状态. 1,查看目前有哪些子机并选择要克隆的子机,我选择关闭test,说明我要克隆的就是它了. 2,查看虚拟机是否关闭. virsh list --al ...
- .Net+MySQL
网上很少用.Net+MySQL的组合的,所以资料比较少,发现一个赶紧分享给大家. 通常数据库连接字符串为:Database=dbname;Data Source=192.168.1.1;Port=33 ...