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 ...
随机推荐
- C# 给自己的代码 添加上 自己的版权信息
如何将自己的代码自动添加版权信息 现在大多数公司都规定程序员在程序文件的头部加上版权信息,这样每个人写的文件都可以区分开来,如果某个文件出现问题就可以快速的找到文件的创建人,用最短的时间来解决问题,常 ...
- 为什么要web语义化
为什么要web语义化 其实wiki的定义里面说得非常清晰了.语义化的好处有三点 有利于搜索 容易兼容不同设备 结构清晰,利于团队的开发.维护
- 【2】开发环境的搭建,Ubuntu14.04
这里使用的是Ubuntu14.04 Unity 更新源 首先,将更新源更换为国内更新源,我这里使用的是网易的更新源 sudo gedit /etc/apt/sources.list deb http: ...
- OS-MAC: An Efficient MAC Protocol for Spectrum-Agile Wireless Networks
IEEE TRANSACTIONS ON MOBILE COMPUTING, VOL. 7, NO. 8, AUGUST 2008 正如之前所说的,这是一个out-of-band local cove ...
- 添加事件监听兼容IE6-8
IE8一下浏览器不支持addEventListener,用attachEvent取而代之,但是在时间类型前面要加上’on‘,例如click时间在attachEvent中要写成onclick. var ...
- C# 如何查看源程序的IL代码
1.打开microsoft visual studio 2008 / visual studio tools / visual studio 2008 命令提示 ,并输入ilda ...
- WPF MultiBinding后台绑定动态属性 属性改变不调用Convert的问题
一开始的写法: MultiBinding mb = new MultiBinding(); Binding b1 = new Binding(); b1.ElementName = "tex ...
- logstash grok 解析Nginx
log_format main '$remote_addr [$time_local] "$request" ' '$request_body $status $body_byte ...
- css案例学习之span边框实现的特殊效果
bottom left bottom right top left top right 配合颜色来使用,实现一些神奇的效果 #menu a span{ height:; width:; /*borde ...
- syscomments 可以用来查找所有关于库中用到的某个关键词的所有相关脚本
syscomments SELECT * FROM syscomments