已经决定不玩空间了,在这里开一贴,用来记录暑假期间刷过的每一题。时间从7.29号开始计算。1. HDU 4883 TIANKENG’s restaurant ( 贪心 )这个是bestcoder #2 的第一题,,居然想半天没有做出来,简直是太弱了,居然又在分情况讨论题目大意:TIANKENG的饭....
分类:
其他好文 时间:
2014-07-29 17:10:32
阅读次数:
189
继续来置换,这次的题也是很简单的。
题目大意:
对于一个长度为n的字符串,有一个数组表示第i个字符放到那个位置。
输入多个字符串,问这样操作k次后的字符串是什么样子的。
解题思路:
对于每一个置换,我们会求出循环节,这样可以减少模拟的次数。
下面是代码:
#include
#include
#include
#include
#include ...
分类:
其他好文 时间:
2014-07-27 11:50:14
阅读次数:
220
一、段错误/RE
1、&
2、数组越界
3、爆栈,
很可能是死循环,ruturn的边界没有处理好,或者是递归的内容里有死循环的部分。
4、线段树
逢写必错,都是build(i*2+1,tmp.mid+1,r);这里忘记加一了。
二、一些莫名其妙的逻辑错误
1、多重的if else 检查是不是有问题,写if else一定要把...
分类:
其他好文 时间:
2014-07-27 11:28:02
阅读次数:
197
Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region...
分类:
其他好文 时间:
2014-07-27 10:42:02
阅读次数:
280
Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should p...
分类:
其他好文 时间:
2014-07-27 10:05:32
阅读次数:
352
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ...
分类:
其他好文 时间:
2014-07-27 09:53:12
阅读次数:
350
这道题运用了置换的知识。
题目大意:
用两两交换的方式给一个数列排序,每交换一次的代价是这两个数之和求最小代价。
解题思路:
对于这种情况,我们在数列中找置换环。每个置换环内的数都是可以回归到它应有的位置上并且不影响其他的置换环。
置换环归位的代价有两种,第一种是用环内最小的数与其他数交换,另一种是用整个数列中最小的数与环内最小的数交换,完成环内所有数的归位后在换...
分类:
其他好文 时间:
2014-07-26 15:18:00
阅读次数:
186
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA...
Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="...
分类:
其他好文 时间:
2014-07-26 14:24:50
阅读次数:
251
Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the e...
分类:
其他好文 时间:
2014-07-26 14:01:44
阅读次数:
219