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’应该被忽略掉,除非这个整 ...
随机推荐
- Python使用Flask框架,结合Highchart,自定义图表样式主题
参考链接:https://www.highcharts.com.cn/docs/themes 1.使用官方提供的主题js文件,只需要在 highcharts.js 后引入对应的文件即可,不用修改原有的 ...
- LINUX:Contos7.0 / 7.2 LAMP+R 下载安装Apache篇
文章来源:http://www.cnblogs.com/hello-tl/p/7568803.html 更新时间:2017-09-21 15:38 简介 LAMP+R指Linux+Apache+Mys ...
- LINUX系统---中级相关操作和知识
LINUX系统的中级,来搞一些LINUX安全相关的东西,还有在公司生成中长搞的集群. RHCS集群 什么是高可用 什么是热备 什么是分布式
- python 列表(二)
列表的其他操作 count 用于统计列表中某个元素出现的次数 Eg: extend 把一个列表添加到另一个列表里面 Index 输出元素的位置即根据内容索引位置 Reverse 把列表元素的位置倒过 ...
- 86-Money Flow Index 资金流量指数指标.(2015.7.3)
Money Flow Index 资金流量指数指标 计算: 1.典型价格(TP)=当日最高价.最低价与收盘价的算术平均值 2.货币流量(MF)=典型价格(TP)×N日内成交金额 3.如果当日MF> ...
- web环境搭建
[服务器] 硬件设备---计算机 软件 [作用] 作为web服务器运行.可以管理web项目 [目录说明] bin :存放各类可以执行文件,如:startup.bat conf:存放各类配置文件,常用配 ...
- QueryParser
[概述] 其他工具类使用比较方便,但不够灵活.QueryParser也实现了较多的匹配方式. [QueryParser的应用] /** * 使用QueryParser进行查询 * @throws Pa ...
- 61. mybatic insert异常:BindingException: Parameter 'name' not found【从零开始学Spring B】
mybatic insert异常:BindingException: Parameter 'name' not found [从零开始学习Spirng Boot-常见异常汇总] 异常信息如下: nes ...
- ORACLE审计小结
ORACLE审计小结 1.什么是审计 审计(Audit)用于监视用户所执行的数据库操作,并且Oracle会将审计跟踪结果存放到OS文件(默认位置为$ORACLE_BASE/admin/$ORACLE_ ...
- [luoguP1868] 饥饿的奶牛(DP)
传送门 先把所有区间按照左端点排序 f[i]表示区间0~i的最优解 #include <cstdio> #include <iostream> #include <alg ...