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






Siriuslzx

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

2012年7月24日

poj - 2253 Frogger
摘要: 这题要说是最短路吧,其实更像DP,因为不需要把路径相加,而是更新为最小值。做这题最大的收获就是我才知道原来优先队列也能间接排序,自己写个cmp就行了,而且原理和sort的cmp一样。真的要感谢che学长。 1 #include <stdio.h> 2 #include <string.h> 3 #include <cmath> 4 #include <queue> 5 #include <vector> 6 using namespace std; 7 int n,m=1; 8 double d[205]; 9 bool used[2 阅读全文
posted @ 2012-07-24 22:56 Siriuslzx 阅读(134) 评论(0) 推荐(0)
 
poj - 3259 Wormholes
摘要: 这题和poj 1860很像,不过那个是求上升回路,这题是求下降回路。 1 #include <stdio.h> 2 #include <string.h> 3 int u[5400],v[5400],w[5400]; 4 int d[505]; 5 int n,m1,m2; 6 bool Bellman() 7 { 8 int i,j; 9 memset(d,0x3f,sizeof(d));10 d[1] = 0;11 for(j = 1; j < n; j++)12 {13 bool ok = 1;14 for(i = ... 阅读全文
posted @ 2012-07-24 22:53 Siriuslzx 阅读(153) 评论(0) 推荐(0)
 
poj - 2240 Arbitrage
摘要: 同样是套汇问题,这题要简单些,我为了多练,换成Floyd算法了。Floyd最大的优点就是写起来简单。 1 #include <stdio.h> 2 #include <string.h> 3 int m,n,cas=1; 4 char name[35][40]; 5 double rate[30][30]; 6 int find(char *s) 7 { 8 for(int i = 0; i < n; i++) 9 if(!strcmp(s,name[i]))10 return i;11 return -1;12 }13 bool Flo... 阅读全文
posted @ 2012-07-24 22:50 Siriuslzx 阅读(163) 评论(0) 推荐(0)
 
poj - 1860 Currency Exchange
摘要: 最短路问题,用Bellman算法判断有无正向环。 1 #include <stdio.h> 2 double M[105],orig; 3 int m,n,s; 4 typedef struct 5 { 6 int u,v; 7 double r,c; 8 void init(int a,int b,double q,double p) 9 {u = a; v = b; r = q; c = p;}10 }Edge;11 Edge ed[205];12 void read_graph()13 {14 int a,b,i;15 double q,w... 阅读全文
posted @ 2012-07-24 22:46 Siriuslzx 阅读(178) 评论(0) 推荐(0)
 
poj - 1258 Agri-Net
摘要: 就是简单的最小生成树,本来用卡尔(Kruskal)算法写也没什么难的,可是偏偏要求用Prim写,搞得我很纠结,总算明白为什么白书里不说它了,因为写起来真的很麻烦,效率也不见得高多少。 1 #include <stdio.h> 2 #include <string.h> 3 #include <queue> 4 using namespace std; 5 int a[105][105]; 6 bool vis[105]; 7 typedef struct 8 { 9 int a,b,w;10 void init(int x,int y,int z)11 {a 阅读全文
posted @ 2012-07-24 08:26 Siriuslzx 阅读(167) 评论(0) 推荐(0)
 
poj - 2367 Genealogical tree
摘要: 简单的拓扑排序,就是每次寻找入度为0的点,高级一些的BFS算法本质上和这个也是一样的。 1 #include <stdio.h> 2 #include <string.h> 3 #include <vector> 4 using namespace std; 5 vector <int > a[105]; 6 int in[105],ans[105]; 7 int main() 8 { 9 int n,m,i,j,t,l;10 while(~scanf("%d",&n))11 {12 memset(in,0,sizeo 阅读全文
posted @ 2012-07-24 08:22 Siriuslzx 阅读(182) 评论(0) 推荐(0)