上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 25 下一页

2014年4月2日

排序 O(nlogn)

摘要: 1.堆排序是一种优秀的排序算法,时间复杂度O(nlogn),主要思想是用数组构造一个最大堆,满足跟节点的value>子节点的value,然后将堆顶元素(value最大)与最后一个叶子节点交换,再调整堆,使其满足最大堆的性质,重复上述步骤n-1次后就得到一个有序序列。 1 #include 2 #include 3 #include 4 #define MAX 111111 5 #define LEFT(i) (i a[i]) largest = l; 14 else largest = i; 15 if(r a[largest]) largest = r; 16 i... 阅读全文

posted @ 2014-04-02 23:22 ~Love() 阅读(248) 评论(0) 推荐(0)

最小距离查询

摘要: 最小距离查询时间限制1000 ms内存限制65536 KB题目描述给定一个由小写字母a到z组成的字符串S,其中第i个字符为S[i](下标从0开始)。你需要完成下面两个操作:INSERT c其中c是一个待输入的字符。你需要在字符串的末尾添加这个字符。保证输入的字符同样是a到z之间的一个小写字母。QUERY x其中x是一个输入的整数下标。对于这个询问,你需要回答在S当中和S[x]相等且与x最近的距离。输入保证x在当前字符串中合法。例如S = "abcaba",如果我们操作:INSERT a 则在S的末端加一个字符a,S变成"abcabaa"。接下来操作QUE 阅读全文

posted @ 2014-04-02 21:49 ~Love() 阅读(308) 评论(0) 推荐(0)

2014年4月1日

ZOJ --- 3516 Tree of Three

摘要: Tree of ThreeTime Limit:2 Seconds Memory Limit:65536 KBNow we have a tree and some queries to deal with. Every node in the tree has a value on it. For one nodeA, we want to know the largest three values in all the nodes of the subtree whose root is nodeA. Node 0 is root of the tree, except it, all o 阅读全文

posted @ 2014-04-01 20:50 ~Love() 阅读(247) 评论(0) 推荐(0)

HDOJ --- Super Jumping! Jumping! Jumping!

摘要: Super Jumping! Jumping! Jumping!Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19996Accepted Submission(s): 8679Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a goo 阅读全文

posted @ 2014-04-01 17:24 ~Love() 阅读(172) 评论(0) 推荐(0)

HDOJ --- 1159 Common Subsequence

摘要: Common SubsequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20815Accepted Submission(s): 8954Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another. 阅读全文

posted @ 2014-04-01 16:37 ~Love() 阅读(133) 评论(0) 推荐(0)

HDOJ --- 1176 免费馅饼

摘要: 免费馅饼Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 22895Accepted Submission(s): 7708Problem Description都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能 阅读全文

posted @ 2014-04-01 14:46 ~Love() 阅读(158) 评论(0) 推荐(0)

POJ --- 1753 Flip Game

摘要: Flip GameDescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 pieces, thus changing the c 阅读全文

posted @ 2014-04-01 12:26 ~Love() 阅读(146) 评论(0) 推荐(0)

2014年3月29日

A+B

摘要: 去年刚学acm时写了一道大数A+B,现在无聊回头看看发现当时写的太屎太长,所以顺便写个精简点的:#include#includeusing namespace std;string s1, s2;int main(){ while(cin >> s1 >> s2){ int j = 0; if(s1.size() = 0;i --) s1[len1--] += s2[i]-48; for(int i = s1.size()-1;i > 0;i --) s2[j++] = (s1[i]-48) % 10, s1[i-1] += (s1[i]-48)... 阅读全文

posted @ 2014-03-29 12:47 ~Love() 阅读(119) 评论(0) 推荐(0)

2014年3月28日

HDOJ --- 1160

摘要: FatMouse's SpeedTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8334Accepted Submission(s): 3715Special JudgeProblem DescriptionFatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a c 阅读全文

posted @ 2014-03-28 11:59 ~Love() 阅读(146) 评论(0) 推荐(0)

2014年3月27日

HDOJ --- 2577

摘要: How to TypeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3261 Accepted Submission(s): 1509Problem DescriptionPirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After ... 阅读全文

posted @ 2014-03-27 21:05 ~Love() 阅读(264) 评论(0) 推荐(0)

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 25 下一页

导航