POJ1007 DNA Sorting

POJ1007 DNA Sorting中英对照翻译与参考解答 POJ 1007 DNA Sorting中英对照翻译与参考解答 阅读详情

DNA Sorting

Time Limit: 1000MS    
Memory Limit: 10000K
Total Submissions: 83488    
Accepted: 33609
Description

One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this measure is 5, since D is greater than four letters 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. 

Input

The first line contains two integers: a positive integer n (0 < n <= 50) giving the length of the strings; and a positive integer m (0 < m <= 100) giving the number of strings. These are followed by m lines, each containing a string of length n.

Output

Output the list of input strings, arranged from ``most sorted'' to ``least sorted''. Since two strings can be equally sorted, then output them according to the orginal order.

Sample Input

```
10 6 
AACATGAAGG 

TTTTGGCCAA 

TTTGGCCAAA 

GATCAGATTT 

CCCGGGGGGA 

ATCGATGCAT
```

Sample Output

```
CCCGGGGGGA 

AACATGAAGG 

GATCAGATTT 

ATCGATGCAT 

TTTTGGCCAA 

TTTGGCCAAA
```


Author:Gannyee 

解题思路:

    将输入的字符串数组用for来比较characterString[i] 的 howGoodOfSort[i]大小,howGoodOfSort[i] 按从小到大的顺序;在进行howGoodOfSort[i]的排序时,characterString[i]也需要跟着howGoodOfSort[i]一同交换i,这样后面characterString[i]输出才会正确。

java 代码:

```
import java.util.Scanner;
public class poj1007 {
        public static void main(String[] args){
                Scanner input = new Scanner(System.in);

                int totalOfEachString = input.nextInt();
                int totalOfLine = input.nextInt();
                int howGoodOfSort[] = new int[totalOfLine];
                String characterString[] = new String[totalOfLine];

                for(int i=0;i < totalOfLine;i++){
                        characterString[i] = input.next();
                        howGoodOfSort[i] = 0;
                        for(int j = 0;j < totalOfEachString;j ++){
                                for(int k = j;k < totalOfEachString;k ++){
                                        if(characterString[i].charAt(j) > characterString[i].charAt(k ))
                                                howGoodOfSort[i] ++;
                                }
                        }
                }

                for(int i =0;i < totalOfLine;i++){
                        for(int j =i;j < totalOfLine;j++){
                                if(howGoodOfSort[i] > howGoodOfSort[j]){
                                        int swap;
                                        String swap1;
                                        swap = howGoodOfSort[i];
                                        howGoodOfSort[i] = howGoodOfSort[j];
                                        howGoodOfSort[j] = swap;
                                        swap1 = characterString[i];
                                        characterString[i] = characterString[j];
                                        characterString[j] = swap1;
                                }
                        }
                        System.out.println(characterString[i]);
                }
        }
}
```

注:互相学习,有不对的地方,请指出,共同探讨学习。

【新能源汽车测试工程师必看!DBC文件50条实战技巧,看懂这篇直接封神】 如果你是新能源汽车研发/测试工程师,还在为信号解析错误、报文找不到、DBC看不懂、实车故障复现不了头疼——那这篇文章,你一定要!在整车电控开发里,DBC = CAN总线的官方字典。没有DBC,报文就是一串乱码;读不懂DBC,测试寸步难行;用不好DBC,排查故障全靠猜。本文总结50条全网最实用、最贴近实车、最能解决问题的DBC技巧,从基础语法到新能源专用信号,从工具操作到故障排错,全部来自一线台架、实车、高压平台实战经验。不废话、不空谈、不玄学,全是能直接落地的硬货! 阅读详情

相关推荐

伺服驱动器启用后对传感器线信号干扰的解决方案

在一些Arduino项目中,研究者发现,当伺服电机启动时,传感器信号会出现显著噪声。例如,在一个假肢项目中,研究者使用光电隔离器成功隔离了伺服驱动器对EMG传感器的干扰。然而,当启用伺服驱动器时,传感器线信号常常受到干扰,导致系统性能下降。传感器线信号是传感器输出的电信号,用于测量物理量,如温度、光线或位置。例如,在一些案例中,伺服驱动器的开关操作可能导致传感器信号出现尖峰或波动,特别是在模拟传感器上更为明显。描述: 使用光电隔离或其他隔离技术,分离伺服驱动器和传感器的电气路径,防止直接干扰。

有用好玩有趣的“电”知识 1466

POJ1007-DNA Sorting

DNA Sorting Time Limit:1000MS Memory Limit:10000K Total Submissions:112218 Accepted:44884 Description One measure of ``unsortedness'' in a sequence is the number of pairs of ...

s0il的博客 630

缺陷检测-金属表面缺陷检测

1介绍 缺陷检测是工业视觉技术中最重要的组成部分。业务广泛,场景丰富,技术难点高、工作量大。针对不同的场景,选择不同的相机和

huneng1991的专栏 5248

POJ 1007 DNA Sorting

POj 1007,属于快速排序吧,下面为题目大意 序列“未排序程度”的一个计算方式是元素乱序的元素对个数。例如:在单词序列“DAABEC'”中,因为D大于右边四个单词,E大于C,所以计算结果为5。这种计算方法称为序列的逆序数。序列“AACEDGG”逆序数为1(E与D)——近似排序,而序列``ZWQM''逆序数为6(它是已排序序列的反序)。 ...

diaobin0154的博客 283

Java判断地图坐标(经度,纬度)是否在多边形区域或圆形区域内

​欢迎光临我的博客查看最新文章:在地图上,可以使用经纬度确定一个位置,如上海体育场(121.449391,31.188228),如果知道了2个地点的经纬度,我们就能在地图上找到其位置及2点的距离,百度地图或高德地图提供了相应的服务;如果将多个坐标点连成多边形区域,如何判断某个坐标点是否在多边形区域内,如下工具类。

river106的博客 3940

AutoSAR系列讲解(入门篇)2.1-AppL概述

该章主要是讲解SWC是如何在ECU中分布的

雪云飞星的博客 4万+

POJ 1007 DNA Sorting

POJ   1007   DNA Sorting                   题目链接:

slicer的技术交流栈 1183

【AUTOSAR-E2E】-2.1-配置E2E:基于E2EPW配置一个RX接收的Signal Group(使用E2E Profile 2)

《共13页精讲》:此法也适用于E2E Profile 4/5/6/7/11/22 目录 1 检查CAN Matrix Arxml/DBC是否满足E2E需求 2 在DaVinci Developer中为Port添加E2E保护 3 在DaVinci Configurator settings设置 4 如何使用应用层的E2E保护 5 结尾 <--返回「Autosar_BSW高阶配置」总目录--> <--返回「Autosar_BSW高阶配置」专栏主页--> <--

「汽车电子助手」的博客 4413

POJ-1007 DNA Sorting

POJ-1007 DNA Sorting 题目链接: 题目大意:序列“未排序程度”的一个计算方式是元素乱序的元素对个数。例如:在单词序列“DAABEC’”中,因为D大于右边四个单词,E大于C,所以计算结果为5。这种计算方法称为序列的逆序数。序列“AACEDGG”逆序数为1(E与D)——近似排序,而序列``ZWQM’’ 逆序数为6(它是已排序序列的反序)。 你的任务是分类DNA字符串(只有ACGT...

鱼头的水题之路 289

数据分享】中国12.5m数字高程模型(DEM)数据(分省)

数据名称:ALOS 12.5m DEM 数据。数据名称:ALOS 12.5m DEM 数据。数据大小:61.5GB。空间分辨率:12.5m。数据大小:61.5GB。空间分辨率:12.5m。

JData_Engineer的博客 5387

Cesium初级开发教程之三十:Primitive集合

教程示例网站:https://thomaz529.github.io。

484

北大ACM(POJ1007-DNA Sorting)

Question:http://poj.org/problem?id=1007 问题点:逆序数及快排。 1 Memory: 248K Time: 0MS 2 Language: C++ Result: Accepted 3 4 #include <iostream> 5 #include <string> ...

aenv6574的博客 229

【DexGraspNet与多指手抓取算法详解】第四章 抓取检测网络架构设计

图 $G=(V, E)$ 包含两类节点:指尖节点 $V_{tip} = \{v_{tip}^i\}_{i=1}^{N_{finger}}$ 与物体表面节点 $V_{obj} = \{v_{obj}^j\}_{j=1}^{N_{surf}}$。节点特征包含位置 $x \in \mathbb{R}^3$ 、法向 $n \in \mathbb{R}^3$ 及视觉特征 $f \in \mathbb{R}^d$。

VectorShift的博客 440

POJ 1007. DNA Sorting

POJ 1007 – DNA Sorting 试题链接:POJ 1007 测试数据:1998 ACM East Central Programming Contest 本题事实上要求一个数组的逆序对个数。所为数组a[1..n]a[1..n]a[1..n]的逆序对,就是对于1≤i,j≤n1 \le i, j \le n1≤i,j≤n,若i<ji < ji<j且a[i]>a[j]a[i] > a[j]a[i]>a[j],则称a[i]a[i]a[i]和a[j]a[j]a[j]互

荔枝的FM 365

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

POJ 1007 DNA Sorting - 字符串比较 - 排序

POJ 1007 DNA Sorting 题意:难度:1星。 /* * POJ 1007 DNA Sorting * 字符串比较;逆序数排序; * * 将序号与对应逆序数绑定: * inversion[i] = inversion[i] * 100 + i; * 排序; * */ #include using namespace std; int main() {

ChenK在学习! 903

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

poj 1007 DNA Sorting

poj 1007 DNA Sorting题意:将字符串以逆序数的大小排序。 题解:rt。#include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> #include <iostream> using namespace std; struct xx { char str[51]; int

学无纸巾 307

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

【原】 POJ 1007 DNA Sorting 逆序数 解题报告

http://poj.org/problem?id=1007 求逆序数的方法: 1、此题每个string只有4种字母,所以可以用类似counting sort的方法来以逆序扫描字符串,并以a[1...3]记录相应字符串组的个数,计算每位数与其后面几位的逆序数。复杂度n。但输入若没有限制就不能靠a[1...3]这样做了,那样的话可能每扫描一个字符++的数组位很多,需要...

ajiaxi111111的博客 218

POJ 1007 DNA Sorting [解题报告] Java

http://www.acmerblog.com/POJ-1007-DNA-Sorting-blog-216.html

expleeve 905

POJ 1007 - DNA Sorting

水题. 早上上机实验的时候无聊看的, 不写完不舒服斯基.

一只冰熊 810

POJ 1007 DNA Sorting

POJ 1007 DNA SortingDescriptionOne measure of unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequenceDAAB

HJ 687

POJ-1007:DNA Sorting

1007:DNA Sorting 时间限制:  1000ms  内存限制:  65536kB 描述 One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For

精灵的博客 4553

POJ1007 DNA Sorting 排序 C语言

题目:http://poj.org/problem?id=1007 题目大意:给出一段DNA序列,按照有序程度降低的顺序输出,也就是以逆序对数增加的顺序输出 思路:记录A、C、G、T出现的次数,每输入一个字符,它出现的个数加1;如果输入A,逆序数加上已出现的C、G、T个数,输入C,逆序数加上已出现的G、T个数,输入G,逆序数加上已出现的T个数,输入T,逆序数不增加。 这样当字符串输...

weixin_30507269的博客 669

POJ 1007.DNA Sorting

题目:http://poj.org/problem?id=1007 AC代码(C++): #include #include using namespace std; struct A{ char a[55]; int s; }; bool cmp(A a, A b){ return a.sb.s; } int main(){ A aa[105]; int n

njyexiong的博客 498

POJ1007 DNA Sorting

DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 85026   Accepted: 34238 Description One measure of ``unsortedness'' in a sequence is the number

长风的专栏 967

[POJ][1007]DNA Sorting

Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this m

软件工程学森 1652

POJ 1007 Java:DNA Sorting

题目描述:大意是给出一些相同长度的字符串,根据这些字符串的逆序数进行排序,输出。 分析:定义一个DNA类,其中包含字符串和该字符串的逆序数两个成员变量,和相关成员函数。对给定的字符串排序,再输出。 AC代码: import java.util.*; public class POJ1007 { public static void main(String[] args){

卡卡罗特 1193
上一篇: configure:&nbsp;error:&nbsp;C&nbsp;co
下一篇: 2014年12月08日
YatKam
博客等级 码龄12年 58粉丝 49原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值