Question:http://poj.org/problem?id=1007
问题点:逆序数及快排。
 Memory: 248K        Time: 0MS
Language: C++ Result: Accepted #include <iostream>
#include <string>
#include <stdlib.h> using namespace std;
struct nm
{
char str[];
int cnt;
};
int mycmp(const void *a,const void *b)
{
nm *nma=(nm*)a;
nm *nmb=(nm*)b;
return nma->cnt-nmb->cnt;
}
int main()
{
int n,m;
nm NM[];
cin>>n>>m;
memset(NM,,sizeof(NM));
for(int i=;i<m;i++)
{
cin>>NM[i].str;
int len=strlen(NM[i].str);
for(int j=;j<len;j++)
{
for(int k=j+;k<len;k++)
{
if(NM[i].str[j]>NM[i].str[k]) NM[i].cnt++;
}
}
}
qsort(NM,m,sizeof(nm),mycmp);
for(int i=;i<m;i++)
{
cout<<NM[i].str<<endl;
}
return ;
}
 

北大ACM(POJ1007-DNA Sorting)的更多相关文章

  1. [POJ1007]DNA Sorting

    [POJ1007]DNA Sorting 试题描述 One measure of ``unsortedness'' in a sequence is the number of pairs of en ...

  2. 算法:POJ1007 DNA sorting

    这题比较简单,重点应该在如何减少循环次数. package practice; import java.io.BufferedInputStream; import java.util.Map; im ...

  3. poj1007——DNA Sorting

    Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are ...

  4. 北大 ACM 分类 汇总

    1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...

  5. DNA Sorting POJ - 1007

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 114211   Accepted: 45704 De ...

  6. 北大ACM - POJ试题分类(转自EXP)

    北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...

  7. poj 1007:DNA Sorting(水题,字符串逆序数排序)

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 80832   Accepted: 32533 Des ...

  8. DNA Sorting 分类: POJ 2015-06-23 20:24 9人阅读 评论(0) 收藏

    DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 88690 Accepted: 35644 Descrip ...

  9. poj 1007 (nyoj 160) DNA Sorting

    点击打开链接 DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 75164   Accepted: 30 ...

  10. [POJ] #1007# DNA Sorting : 桶排序

    一. 题目 DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 95052   Accepted: 382 ...

随机推荐

  1. TCP/IP协议族-----13、运输层简单介绍

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaGVrZXdhbmd6aQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  2. 【JavaScript】关于JS中的constructor与prototype

    最初对js中 object.constructor 的认识: 在学习JS的面向对象过程中,一直对constructor与prototype感到很迷惑,看了一些博客与书籍,觉得自己弄明白了,现在记录如下 ...

  3. 编辑器TP

    http://www.itshipin.com/blog/archives/category/php/thinkphp

  4. Android创建桌面快捷方式

    在桌面上创建特定界面的快捷入口,icon和title根据请求参数命名.在网上收集的一些相关资 料,在使用intent发送广播的时候,一些型号的收集会有问题,如魅族MX,红米,以及华为,使用setCla ...

  5. Bash脚本编程基础

    为实现某个任务,将许多命令组合后,写入一个可执行的文本文件的方法,称为Shell脚本编程. 按照应用的Shell环境不同,可以将Shell脚本分为多种类型.其中最常见的是应用于Bash和Tcsh的脚本 ...

  6. GNU-ARM汇编

    GNU ARM 汇编指令(2008-10-29 00:16:10) 标签:linux gnu arm 汇编指令 it 分类:技术文摘 第一部分 Linux下ARM汇编语法尽管在Linux下使用C或C+ ...

  7. C# 读取文件的修改时间、访问时间、创建时间

    C# 获取文件的各个时间如下: 表2<ccid_nobr> 属性 功能和用途 Attributes 返回和文件相关的属性值,运用了FileAttributes枚举类型值 CreationT ...

  8. 10分钟学会AngularJS的数据绑定

     前言:为什么要用AngularJS?  相信用过.NetMVC的人都知道用rezor绑定数据是一件很爽的事情,C#代码直接在前台页面中输出.然后这种比较适用于同步请求.   当我们的项目离不开异步请 ...

  9. find your present (2)

    Problem Description In the new year party, everybody will get a "special present".Now it's ...

  10. JavaScript工厂模式代码

    function createPerson(name,age,job){ var o=new Object(); o.name=name; o.age=age; o.job=job; o.sayNam ...