算法:POJ1007 DNA sorting
这题比较简单,重点应该在如何减少循环次数。
package practice; import java.io.BufferedInputStream;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap; /**
* DNA sorting
*
* @author caiyu
* @date 2014-11-5
*/
public class POJ1007 {
public static void main(String[] args) {
Scanner cin = new Scanner(new BufferedInputStream(System.in));
int l = cin.nextInt();
int t = cin.nextInt(); String s;
Map<Integer, String> m = new TreeMap<Integer, String>();
for (int i = 0; i < t; i++) {
s = cin.next();
int[] count = new int[l];
int inversion = 0;
for (int j = 0, len = l - 1; j < len; j++) {
count[j] = s.charAt(j);
for (int h = 0; h < j; h++) {
if (count[h] > count[j])
inversion++;
}
}
m.put(inversion, s);
} for (String x : m.values()) {
System.out.println(x);
}
}
}
算法:POJ1007 DNA sorting的更多相关文章
- [POJ1007]DNA Sorting
[POJ1007]DNA Sorting 试题描述 One measure of ``unsortedness'' in a sequence is the number of pairs of en ...
- poj1007——DNA Sorting
Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are ...
- [POJ] #1007# DNA Sorting : 桶排序
一. 题目 DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 95052 Accepted: 382 ...
- DNA Sorting POJ - 1007
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 114211 Accepted: 45704 De ...
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- 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: 95437 Accepted: 38399 Des ...
- DNA Sorting(排序)
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) DNA Sorting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
随机推荐
- REDIS源码中一些值得学习的技术细节02
Redis中散列函数的实现: Redis针对整数key和字符串key,采用了不同的散列函数 对于整数key,redis使用了 Thomas Wang的 32 bit Mix Function,实现了d ...
- IplImage 结构解读
IplImage 结构解读: typedef struct _IplImage { int nSize; /* IplImage大小,等于wi ...
- Java 基本数据类型(新手必看资料)
变量就是申请内存来存储值.也就是说,当创建变量的时候,需要在内存中申请空间. 内存管理系统根据变量的类型为变量分配存储空间,分配的空间只能用来储存该类型数据. 因此,通过定义不同类型的变量,可以在内存 ...
- Matlab(3) -- 编写M文件(函数)
转自:http://blog.csdn.net/misskissc/article/details/8178089 matlab的命令编辑窗口(Command Window)界面主要是用来调用系统命令 ...
- [python] os.path说明
os.path - Common pathname manipulations操作 This module implements some useful functions on pathnames. ...
- (Python)异常处理try...except、raise
一.try...except 有时候我们写程序的时候,会出现一些错误或异常,导致程序终止.例如,做除法时,除数为0,会引起一个ZeroDivisionError 例子: a=10 b=0 c=a/b ...
- php设计模式--单例模式
单例模式(Singleton Pattern 单件模式或单元素模式) 单例模式确保某个类只有一个实例,而且自行实例化并向整个系统提供这个实例. 单例模式是一种常见的设计模式,在计算机系统中,线程池.缓 ...
- Win7 64位qt-windows-x86-msvc2015-5.6.0 DLL依赖库打包
今天开始系统的学习QT,第一个测试的问题就是在纯净的系统中如何正常运行,也就是找出QT生成的exe的依赖库问题 网上搜了下可以简单粗暴的用 D:\Qt\Qt5.6.0\5.6\msvc2015\bin ...
- 「2014-3-17」C pointer again …
记录一个比较基础的东东-- C 语言的指针,一直让人又爱又恨,爱它的人觉得它既灵活又强大,恨它的人觉得它太过于灵活太过于强大以至于容易将人绕晕.最早接触 C 语言,还是在刚进入大学的时候,算起来有好些 ...
- linux启动流程
看了深入理解linux内核一书的最后对linux启动流程的介绍,下面就把我能理解的写一下吧: bios(硬件加电自检POST,寻找第一个启动设备) the boot loader(可以从硬盘启动也可以 ...