自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 AtCoder Tasks B インタラクティブ練習 (Interactive Sorting)

优化插入法解决交互排序问题

2017-06-10 01:33:30 3205

原创 HDU3388 - Coprime(容斥+二分)

DescriptionPlease write a program to calculate the k-th positive integer that is coprime with m and n simultaneously. A is coprime with B when their greatest common divisor is 1.  Inpu

2017-08-10 23:57:34 253

原创 HDU-3681 Prison Break (bfs + 二分枚举)

题目大意:要求主角打开所有开关从而能打开监狱从而逃走。要求:主角梅走一步都会消耗一单位的能量,不能通过'D',‘G’是补充能量的地方(意味着在此处主角可将能量补到电池容量大小),可以补满能量,‘Y’是开关,主角刚开始能量也是满的,问主角想要逃走电池容量至少得有多少。思路:会随着主角移动而改变的物件有:能量包,开关。状态压缩能量包和开关的状态,从小往大枚举最大电容量,看rob

2017-07-29 10:29:33 289

原创 POJ 3009 Curling 2.0(bfs + 状态压缩)

这题看到很多人用深搜,而本渣渣看到这题的第一眼就觉得可以用状态压缩上宽搜做,然而有个细节没处理好导致越界。。。讲真,为了能发现这个bug我花了整整3小时。。这里给自己提个醒,写代码一定要细心呀!!!#include#include#include#include#include#include#include#include#include#include#incl

2017-07-17 19:00:07 243

原创 Codeforces Educational Codeforces Round 22

最近的CF的Codeforces Educational Codeforces Round 22 比赛题,写了前三道的思路和代码,有兴趣的可以自己尝试下后三道

2017-06-12 00:14:13 299

原创 重构二叉树(XTU 1046)

重构二叉树

2017-05-01 15:58:20 332

原创 Editing a Book UVA - 11212(DFS+IDA*)

一块好的IDA*算法的试验田

2017-04-22 00:15:01 207

原创 hdu 1043-Eight(经典八数码问题)(单向广搜 A* 状态压缩)

一开始接触这题是在poj上,当时直接单广加A*就0ms水过,但放HDU上就一直TLE,想一想发现如果结果是solvable的话这种方法也会把所有状态都查一遍,那还要算法干嘛,所以就开始通过数学方法解决,不难发现,除x外的数组成的数列无论怎么移动都不会改变原数列的奇偶性,这样就能刷下一大堆多余查询了。其余细节注意处理好就行。AC代码(171ms):#include#include#i

2017-04-16 00:45:41 265 1

原创 Krypton Factor UVA - 129(DFS回溯)

每次取一个元素,符合就进行下次的选取就成。唯一需要注意的是本题的格式必须看仔细,题目中讲的很详细:As such a sequence is potentially very long, split it into groups of four (4) characters separated bya space. If there are more than 16 such groups,

2017-04-14 17:28:12 335

原创 CF-287E(Main Sequence) greedy(贪心)

As you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received the shaman knowledge about the correct bracket sequences. The shamans of Ultima Thule have been usin

2017-04-14 15:30:24 534

原创 Poj-1731 Orders(生成可重集的排列)

虽说STL标准库中有next_permutation这样的函数来秒掉这题,但如果用递归深搜呢?一个不小心就TLE了。为了提高代码的可读性,稍微写得复杂了点ac代码如下 #include#include#includeusing namespace std;char str[210];int sn[29], vn[29];char vec[210], ed = '\0

2017-04-13 00:36:39 247

原创 Fractions Again?! UVA - 10976

水题,控制好范围就行ac代码#includetypedef long long ll;using namespace std;int x[10010], y[10010];int main() { int k; while(scanf("%d", &k) != EOF) { int cnt = 0; for(int i=k+1; i<=2*k; i++) {

2017-04-12 13:18:51 199

原创 UVA - 11059( Maximum Product )

#include#include#include#includetypedef long long ll;using namespace std;int main() { int n, kase=1; while(cin >> n) { ll a[30], mul = 0; for(int i=0; i> a[i]; for(int i=0; i<n; i++) {

2017-04-12 12:43:33 227

原创 uva816 Abbott's Revenge (BFS+回溯)

题目大意给你个迷宫,求最短路,不过在每个点转弯的方向受进入方向的限制思路确定好每个点的状态,再用bfd求出最短路,注意记得用个数组保存节点,以方便输出事实上很多细节都是参考刘汝佳老师的,感觉非常巧妙#include#include#include// #include 由于后面用了的y1在cmath中已定义,所以必须放弃它 #include#include#

2017-04-11 00:23:34 339

原创 UVa 1103 - Ancient Messages (染色+dfs)

#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define f(i, a, b) for(int i=a; i<b; i++)#define rf(i, a, b) for(int i=a;

2017-04-10 19:12:47 300

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除