北大ACM(POJ1007-DNA Sorting)
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)的更多相关文章
- [POJ1007]DNA Sorting
[POJ1007]DNA Sorting 试题描述 One measure of ``unsortedness'' in a sequence is the number of pairs of en ...
- 算法:POJ1007 DNA sorting
这题比较简单,重点应该在如何减少循环次数. package practice; import java.io.BufferedInputStream; import java.util.Map; im ...
- poj1007——DNA Sorting
Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are ...
- 北大 ACM 分类 汇总
1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...
- DNA Sorting POJ - 1007
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 114211 Accepted: 45704 De ...
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- 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: 95052 Accepted: 382 ...
随机推荐
- 【转】网络中的AS自治域
1. 什么是AS自治域? 全球的互联网被分成很多个AS 自治域,每个国家的运营商.机构.甚至公司等都可以申请AS号码,AS号码是有限的,最大数目是65536.各自分配的IP地址被标清楚属于哪个AS号码 ...
- 一个jQuery扩展工具包
带有详尽注释的源代码: var jQuery = jQuery || {}; // TODO // ###################################string操作相关函数### ...
- 用AJAX技术聚合RSS
有时候,你的Blog可能需要这样的功能: 在自己Blog上聚合并显示朋友Blog的最新文章,这样方便自己及时了解朋友的消息,另外,也方便访问者找到和本Blog相关的blog和文章. 这个功能你可以叫它 ...
- QML学习笔记之三
import QtQuick 1.1 Row{ spacing:2 Rectangle{color:"red";width:50;height:50} Rectangle{colo ...
- nicehair
https://github.com/lanyj189/nicehair https://github.com/eltld/nicehair https://github.com/pepoc/Cust ...
- 用Systemtap探索MySQL
http://www.actionsky.com/docs/archives/168#Systemtap 目录 1 Systemtap 2 Systemtap 观测点的支持程度 2.1 官方编译的My ...
- 548 - Tree (UVa OJ)
Tree You are to determine the value of the leaf node in a given binary tree that is the terminal nod ...
- jquery ui 改写cloes事件
htmlAjax:{//模板ajax请求参数设置项 url:"template/task/task_create.html", data ...
- Creating a CSRF protection with Spring 3.x--reference
reference from:http://info.michael-simons.eu/2012/01/11/creating-a-csrf-protection-with-spring-3-1/ ...
- shell 学习笔记
<Linux命令行与shell脚本编程大全>笔记 wkss 其他:http://www.cnblogs.com/pengdonglin137/p/3528303.html 一.基本命令 ...