C# ACM poj1007
求逆序数,快排
public static void acm1007(int a, string[] c)
{
Dictionary<int, string> dic = new Dictionary<int, string>();
int[] i = new int[a];
var j = ;
foreach (var item in c)
{
int k = Acm1007Unit(item);
if (!dic.ContainsKey(k))
{
i[j] = k;
j++;
dic.Add(k, item + ",");
}
else
{
dic[k] += item + ",";
i[j] = -;
j++;
}
}
QSortDIY(i, , i.Length - ); for (int jjj = ; jjj < i.Length ; jjj++)
{
if (i[jjj] != -)
{
Console.Write(dic[i[jjj]]);
}
} }
public static int Acm1007Unit(string a)
{
int anum = ;
int cnum = ;
int gnum = ; int r = ;
for (int i = a.Length - ; i >= ; i--)
{
switch (a[i])
{
case 'A':
anum++;
break;
case 'C':
r += anum;
cnum++;
break;
case 'G':
r += anum + cnum;
gnum++;
break;
case 'T':
r += anum + cnum + gnum;
break;
}
}
return r;
}
public static void QSortDIY(int[] array, int low, int high)
{
if (low >= high)
{
return;
}
int ie = QSortUnit(array, low, high);
QSortDIY(array, low, ie - );
QSortDIY(array, ie + , high);
}
private static int QSortUnit(int[] array, int low, int high)
{
int key = array[low];
while (low < high)
{
while (array[high] >= key && high > low)
{
--high;
}
array[low] = array[high];
while (array[low] <= key && high > low)
{ ++low;
}
array[high] = array[low];
}
array[low] = key;
return high;
}
C# ACM poj1007的更多相关文章
- ACM训练计划建议(写给本校acmer,欢迎围观和指正)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
- ACM训练计划建议(转)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- SCNU ACM 2016新生赛决赛 解题报告
新生初赛题目.解题思路.参考代码一览 A. 拒绝虐狗 Problem Description CZJ 去排队打饭的时候看到前面有几对情侣秀恩爱,作为单身狗的 CZJ 表示很难受. 现在给出一个字符串代 ...
- SCNU ACM 2016新生赛初赛 解题报告
新生初赛题目.解题思路.参考代码一览 1001. 无聊的日常 Problem Description 两位小朋友小A和小B无聊时玩了个游戏,在限定时间内说出一排数字,那边说出的数大就赢,你的工作是帮他 ...
- acm结束了
最后一场比赛打完了.之前为了记录一些题目,开了这个博客,现在结束了acm,这个博客之后也不再更新了. 大家继续加油!
- 关于ACM的总结
看了不少大神的退役帖,今天终于要本弱装一波逼祭奠一下我关于ACM的回忆. 从大二上开始接触到大三下结束,接近两年的时间,对于大神们来说两年的确算不上时间,然而对于本弱来说就是大学的一半时光.大一的懵懂 ...
- 第一届山东省ACM——Phone Number(java)
Description We know that if a phone number A is another phone number B’s prefix, B is not able to be ...
- 第一届山东省ACM——Balloons(java)
Description Both Saya and Kudo like balloons. One day, they heard that in the central park, there wi ...
随机推荐
- 一些好用的nginx第三方模块
一些好用的nginx第三方模块 转自;http://macken.iteye.com/blog/1963301 1.Development Kit https://github.com/simpl/ ...
- IDF实验室-简单的ELF逆向 writeup
题目:http://ctf.idf.cn/index.php?g=game&m=article&a=index&id=39 下载得到ElfCrackMe1文件,直接用IDA打开 ...
- IIS连接数
IIS连接数,也叫IIS并发数(Current Connections),是指同一时间内,有多少个对服务器的请求 一般情况下一个浏览器会占用2个IIS连接 同一个浏览器(IE.Firefox等)窗口中 ...
- hdu 5446 Unknown Treasure lucas和CRT
Unknown Treasure Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- C++ Primer 学习笔记_95_用于大型程序的工具 --多重继承与虚继承
用于大型程序的工具 --多重继承与虚继承 引言: 大多数应用程序使用单个基类的公用继承,可是,在某些情况下,单继承是不够用的,由于可能无法为问题域建模,或者会对模型带来不必要的复杂性. 在这些情况下, ...
- careercup-C和C++ 13.5
13.5 谈谈C语言关键字”volatile”的意义(或重要性)? 解答 关键字volatile的作用是指示编译器,即使代码不对变量做任何改动,该变量的值仍可能被外界修改.操作系统.硬件或其他线程都可 ...
- [Effective C++ --017]以独立语句将newed对象置入智能指针
这一节也比较简单,先假设我们有如下的函数: int foo(); void memFoo(shared_ptr<T> pw, int foo); 现在假设我们要调用memFoo函数: me ...
- C#_MVC3之使用Authorize简单的验证登录(一)
第一步,自定义 AuthorizeAttribute. public class CustomAuthorizeAttribute : AuthorizeAttribute { public over ...
- 为ListView添加头和脚
转自:https://software.intel.com/zh-cn/blogs/2014/12/15/android-listview-addheaderview-addfooterview ...
- 用expect做自动应答脚本
Expect是一个用来实现自动交互功能的软件套件 (Expect [is a] software suite for automating interactive tools).使用它系统管理员可以创 ...