hdoj--1379--DNA Sorting(排序水题)
DNA Sorting
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2357 Accepted Submission(s): 1158
to its right and E is greater than one letter to its right. This measure is called the number of inversions in the sequence. The sequence ``AACEDGG'' has only one inversion (E and D)--it is nearly sorted--while the sequence ``ZWQM'' has 6 inversions (it is
as unsorted as can be--exactly the reverse of sorted).
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.
of length n.
1 10 6
AACATGAAGG
TTTTGGCCAA
TTTGGCCAAA
GATCAGATTT
CCCGGGGGGA
ATCGATGCAT
CCCGGGGGGA
AACATGAAGG
GATCAGATTT
ATCGATGCAT
TTTTGGCCAA
TTTGGCCAAA
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
char s[55];
int num,p;
}q[1010];
bool cmp(node s1,node s2)
{
if(s1.p==s2.p)
return s1.num<s2.num;
return s1.p<s2.p;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++)
{
scanf("%s",q[i].s);
q[i].num=i;
q[i].p=0;
for(int j=0;j<n;j++)
{
for(int k=j+1;k<n;k++)
{
if(q[i].s[j]>q[i].s[k])
{
q[i].p++;
}
}
}
}
sort(q,q+m,cmp);
for(int i=0;i<m;i++)
printf("%s\n",q[i].s);
}
return 0;
}
hdoj--1379--DNA Sorting(排序水题)的更多相关文章
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDOJ(HDU) 1859 最小长方形(水题、、)
Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- PAT甲题题解-1012. The Best Rank (25)-排序水题
排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...
- PAT甲题题解-1062. Talent and Virtue (25)-排序水题
水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...
- HDOJ/HDU 2560 Buildings(嗯~水题)
Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...
- HDU 1379:DNA Sorting
DNA Sorting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- hdu1106 排序水题
Problem Description 输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整 ...
随机推荐
- [Python3网络爬虫开发实战] 6.3-Ajax结果提取
这里仍然以微博为例,接下来用Python来模拟这些Ajax请求,把我发过的微博爬取下来. 1. 分析请求 打开Ajax的XHR过滤器,然后一直滑动页面以加载新的微博内容.可以看到,会不断有Ajax请求 ...
- linux中PHP安装扩展包(mongodb为例)
相对于windows中的PHP扩展,只需要在下载相应的dll资源,并且添加配置在php.ini之后即可. 但是在linux安装扩展时,需要进行编译安装. 这里以lnmp一键安装包为例(php.ini位 ...
- linux命令 host-常用的分析域名查询工具
博主推荐:更多网络测试相关命令关注 网络测试 收藏linux命令大全 host命令是常用的分析域名查询工具,可以用来测试域名系统工作是否正常. 语法 host(选项)(参数) 选项 -a:显示详细的 ...
- css布局的各种FC简单介绍:BFC,IFC,GFC,FFC
什么是FC? Formatting Context,格式化上下文,指页面中一个渲染区域,拥有一套渲染规则,它决定了其子元素如何定位,以及与其他元素的相互关系和作用. BFC 什么是BFC Block ...
- python 安装模块 更新模块
#显示模块pip list #显示过期模块pip list --outdated #安装模块pip install xxx #升级模块pip install --upgrade xxx
- Android Studio 使用图片
首先将图片放在drawable下 然后: <ImageView android:layout_width="wrap_content" android:layout_heig ...
- Dijkstra算法C++实现总结
问题描述 求无负权图中点s到点t的最短凝聚力 备注 标准说法中,"缩短"/"松弛"(relax)操作是对边进行的.下面为了行文方便,将其拓展到点.即以下操作,其 ...
- 开启POP3/SMTP服务
实现发送邮件时需要先启用POP3/SMTP服务(以qq邮箱和网易邮箱启用为例) 一 qq邮箱启用 二.网易邮箱开启POP3/SMTP服务 至此:服务已开启
- BNUOJ 5235 Starship Troopers
Starship Troopers Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on HDU. Origi ...
- 使用HttpClient调用第三方接口
最近项目中需要调用第三方的Http接口,这里我用到了HttpClient. 首先我们要搞明白第三方接口中需要我们传递哪些参数.数据,搞明白参数以后我们就可以使用HttpClient调用接口了. 1.调 ...