感觉已经没啥心情用JAVA和PAT斗智斗勇了,会内存超限,是不是读进来就内存超限了?二分做的方法有点bug,又写了一个merge sort的,想着百万数量级应该不会超时吧这都超时也太蛋疼了,结果居然内存爆了... 1 import java.util.*; 2 import java.io.*; 3...
分类:
其他好文 时间:
2014-11-01 17:44:42
阅读次数:
179
1.插入排序—直接插入排序(Straight Insertion Sort)基本思想: 将一个记录插入到已经排序好的有序表中,从而得到一个新、记录数增1的有序表。即:先将序列的第一个记录看成是一个有序的子序列,然后从第二个记录逐个进行插入,直至整个序列有序为止。 要点:设立哨兵,作为临时...
分类:
编程语言 时间:
2014-11-01 17:27:53
阅读次数:
165
Robotic Sort
Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2505 Accepted Submission(s): 1109
Problem Description
Somewhere deep in...
分类:
其他好文 时间:
2014-11-01 16:19:04
阅读次数:
222
bool compare(const pair &a,const pair&b)
{
return a.first v;
v.push_back(make_pair(4,2));
v.push_back(make_pair(2,4));
sort(v.begin(),v.end(),compare);...
分类:
编程语言 时间:
2014-11-01 14:54:47
阅读次数:
1098
awk于1977年出生,今年36岁本命年,sed比awk大2-3岁,awk就像林妹妹,sed就是宝玉哥哥了。所以林妹妹跳了个Topless,他的哥哥sed坐不住了,也一定要出来抖一抖。sed全名叫stream editor,流编辑器,用程序的方式来编辑文本,相当的hacker啊。sed基本上就是玩正...
分类:
其他好文 时间:
2014-10-31 23:32:27
阅读次数:
331
思路:sort+low_bound()二分
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
vectorv;
int n,m;
int cas=1;
while(scanf("%d%d",&n,&m),n||m)
...
分类:
其他好文 时间:
2014-10-31 22:19:20
阅读次数:
261
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the integers ...
分类:
其他好文 时间:
2014-10-31 17:29:05
阅读次数:
129
对"black,green,yellow,pin,red"几个单词排序01#include #include void sort(char (*p)[20],int n){ char *q; char b[20]; q=b; int i,j; for(i=0;i0) { strcpy(q,...
分类:
编程语言 时间:
2014-10-31 15:09:10
阅读次数:
308
堆排序(heap sort) 具体解释 及 代码(C++)本文地址:http://blog.csdn.net/caroline_wendy堆排序包括两个步骤:第一步:是建立大顶堆(从大到小排序)或小顶堆(从小到大排序), 从下往上建立; 如建堆时, s是从大到小;第二步: 是依次交换堆顶和堆底, 并...
分类:
编程语言 时间:
2014-10-31 13:23:24
阅读次数:
275
之前是通过hash来做,O(n)。这次为了熟悉通用性的解法,通过双指针来做。时间复杂度为O(nlogn)(即sort的复杂度)。主要是关于sort的用法上不太熟,关于自定义sort规则。C++ Reference中给的示例代码如下: 1 // sort algorithm example 2 #in...
分类:
其他好文 时间:
2014-10-31 11:30:15
阅读次数:
193