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 ...
随机推荐
- python运维开发(十七)----jQuery续(示例)web框架django
内容目录: jQuery示例 前端插件 web框架 Django框架 jQuery示例 dom事件绑定,dom绑定在form表单提交按钮地方都会绑定一个onclick事件,所有查看网站的人都能看到代码 ...
- 使用PHP从web访问mysql数据库
一. web数据库构架的工作原理 1. 用户由浏览器发出HTTP请求,请求特定的web页面. 2. web服务器接受接收到对特定页面的请求,检索相应文件,并将其传递给php引擎处理. 3. php引擎 ...
- C语言IO操作总结
C语言IO操作总结C程序将输入看做字节流,流的来源是文件.输入设备.或者另一程序的输入:C程序将输出也看做字节流:流的目的是文件.视频显示等: 文件处理:1 :fopen("filename ...
- KeyTool
http://ln-ydc.iteye.com/blog/1335213 http://lukejin.iteye.com/blog/605634
- JavaScript为unicode编码转换为中文
代码laycode - v1.1 关于这样的数据转换为中文问题,常用的以下方法. 1. eval解析或new Function("'+ str +'")() str = eval ...
- 【Android病毒分析报告】 - ZooTiger “集恶意推广、隐私窃取、恶意吸费于一体”
本文章由Jack_Jia编写,转载请注明出处. 文章链接:http://blog.csdn.net/jiazhijun/article/details/11772379 作者:Jack_Jia ...
- bzoj1650 [Usaco2006 Dec]River Hopscotch 跳石子
Description Every year the cows hold an event featuring a peculiar version of hopscotch that involve ...
- 瑞柏匡丞:App对新媒体的影响
当下App的迅猛发展是媒体进入开放平台时代的折射,作为最具新媒体特质的代表,App充满了社交性与交互性,并有效整合了传统媒体和新媒体的内容和服务.“什么是新媒体”——这个新媒体时代最为核心的命题,实际 ...
- UESTC_Judgment Day CDOJ 11
Today is the judgment day. The world is ending and all man will pay for their guilt and sin. Now the ...
- 企业OA面临的问题,以及解决问题的推荐
现在的企业不管大小都趋于软件话,而办公用的OA软件更是成为了企业中不可获取的一环,一个好的软件能让企业发展的更加顺利,而一个不合适的软件可能让公司哀声怨道反而起了反作用! OA ...