• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






Siriuslzx

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理
上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页

2012年7月20日

poj - 1742 Coins
摘要: 楼教主的“男人八题”之一,多重背包问题,che男让我用单调队列来做,可是我觉得单调队列太头疼,就搜了另外一种思路,然后自己写了一个。于是诡异的事情发生了,该题的Disscus里面也有一个我和的思路一模一样的代码,代码也几乎一模一样,连开的数组大小都是一样的,想说我不是抄的都没人信啊,郁闷。这是Disscus里面的: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 6 bool can_pay[100005]; 7 int use_a 阅读全文
posted @ 2012-07-20 23:51 Siriuslzx 阅读(277) 评论(0) 推荐(0)
 

2012年7月19日

poj - 1651 Multiplication Puzzle
摘要: 简单DP,矩阵相乘,这次尝试自己写一个,居然过了,很好。本来今天还水了poj 1088 二维空间最长下降(上升)序列和 poj 3624 超水0,1背包,也想贴出来凑数的,可是zxpn同志说,这么水的题你也好意思贴出来,只好做罢。 1 #include <stdio.h> 2 #include <string.h> 3 int f[100][100],a[105]; 4 int dp(int i,int j) 5 { 6 int k, min, &ans = f[i][j]; 7 if(f[i][j] != -1) 8 return ans; 9 if(... 阅读全文
posted @ 2012-07-19 23:23 Siriuslzx 阅读(184) 评论(0) 推荐(0)
 
poj - 1887 Testing the CATCHER
摘要: 曾经的WF题,如今我一个小菜鸟都能做出来了,可见时代在进步啊。这题用nlogn算法做的,由于不知道有多少个数,所以数组要开大些,反正我随便开了一个是够了。 1 #include <stdio.h> 2 #include <string.h> 3 int c[2000],len=-1; 4 int find(int t) 5 { 6 int le=0,ri=len,mid; 7 while(le <= ri) 8 { 9 mid = (le+ri) >> 1;10 if(c[mid] == t)11 return m... 阅读全文
posted @ 2012-07-19 23:18 Siriuslzx 阅读(274) 评论(0) 推荐(0)
 

2012年7月18日

zoj - 1008 Gnome Tetravex
摘要: 典型的回溯,这题我一拖再拖,拖了好几天,然后觉得自己写不出来。可是今天搜了一下,答案是如此简短明了,我真的很诧异,难道我真的不行?好吧,我是一个回溯都没写过,所以才会这么力不从心,决定做几题练一练。 1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 int q[25]; 5 int s[25][4]; 6 int num[25]; 7 int flag,n,l; 8 void dfs(int len) 9 {10 if(flag)11 return;12 if(len == n... 阅读全文
posted @ 2012-07-18 22:37 Siriuslzx 阅读(301) 评论(0) 推荐(0)
 

2012年7月17日

poj - 3126 Prime Path
摘要: 今天这题算是巩固BFS了,昨天的经验是把“判断”转到一个位置,就能大幅度提高效率,今天更奇葩,我按照昨天总结的“完善”的方法,超了一次又一次时,仿佛昨天都是浮云。最后又把判断移了一个位置,奇迹出现了,从TLE变为16ms,难怪说搜索的效率都很低,今天算是明白了。 1 #include <stdio.h> 2 #include <string.h> 3 bool isprime[10005],vis[10005]; 4 int a,b,step[4000],d[4]; 5 int head,end,q[4000]; 6 int bfs() 7 { 8 int m,n,i, 阅读全文
posted @ 2012-07-17 23:57 Siriuslzx 阅读(177) 评论(0) 推荐(0)
 

2012年7月16日

poj - 1915 Knight Moves
摘要: 经典的走马步,BFS里的基友,啊不,基础题,我却花了老长时间。今天做这题时遇到了两个奇葩问题,一是数组越界了居然不RE,当初我的队列只开了300+,然后head都飙到460了程序还正常运行;另一个就是我在BFS里没有对x2,y2进行任何修改,它居然姚明进去,郭敬明出来了。最后还是要感谢Samsara帮我找到了问题,把数组开大了。我想,说不定第二个问题就是由第一个引起的,难道是CodeBlocks太智能了,知道我写的是队列,然后自动*#$…… 1 #include <stdio.h> 2 #include <string.h> 3 int map[310][310],en 阅读全文
posted @ 2012-07-16 23:32 Siriuslzx 阅读(173) 评论(0) 推荐(0)
 

2012年7月15日

poj - 2255 Tree Recovery
摘要: 今天只水了一道二叉树重建,本来白书上是有代码的,可惜我的白书锁教室了,只好自己想了一下,还算可以。 1 #include <stdio.h> 2 #include <string.h> 3 int cnt; 4 char c[30]; 5 void build(char * s,char * t,int l) 6 { 7 if(l == 1) 8 {c[cnt++] = *s; return ;} 9 int n = strchr(t,s[0]) - t;10 if(n) build(s+1,t,n);11 if(l-n-1)12 bui... 阅读全文
posted @ 2012-07-15 22:27 Siriuslzx 阅读(125) 评论(0) 推荐(0)
 

2012年7月14日

spoj - 7259 LITE
摘要: 涉及到lazy思想的线段树,难度大一些,不过幸好只有一种操作,扛得下。 1 #include <stdio.h> 2 #include <string.h> 3 #define N 100005 4 int tree[4*N],D; 5 bool rev[4*N]; 6 void build(int cur,int x,int y) 7 { 8 int mid=(x+y)>>1,lc=cur<<1,rc=lc|1; 9 rev[cur] = 0;10 tree[cur] = 0;11 if(x == y)12 return ;13 bui... 阅读全文
posted @ 2012-07-14 00:19 Siriuslzx 阅读(202) 评论(0) 推荐(0)
 
poj - 2352 Stars
摘要: 典型线段树,因为Input已经按Y坐标处理过了,所以程序只需处理X值就行了,也就是查询、更新。 1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 const int N = 32005; 5 int tree[4*N],D; 6 int level[15010]; 7 void update(int n) 8 { 9 for(; n^1; n>>=1)10 tree[n>>1] = tree[n] + tree[n^1];11 }12 void query(in 阅读全文
posted @ 2012-07-14 00:15 Siriuslzx 阅读(142) 评论(0) 推荐(0)
 
poj - 2182 Lost Cows
摘要: 这题的意思是有编号1~N的牛,给出每个(除了第一个)牛前面比它号小的牛的个数,输出牛是怎么排的队。没想出怎么用线段树做,就当模拟题做了。 1 #include <stdio.h> 2 #include <string.h> 3 int a[8500],ans[8500]; 4 bool vis[8500]; 5 int main() 6 { 7 int n,i,j,cnt; 8 while(~scanf("%d",&n)) 9 {10 memset(vis,0,sizeof(bool)*n);11 for(i = 1; i < n; i 阅读全文
posted @ 2012-07-14 00:13 Siriuslzx 阅读(209) 评论(0) 推荐(0)
 
上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页