摘要: a 阅读全文
posted @ 2014-12-27 16:51 linyvxiang 阅读(111) 评论(0) 推荐(0) 编辑
摘要: systemtap是内核开发者必须要掌握的一个工具,本文我将简单介绍一下此工具,后续将会有系列文章介绍systemtap的用法。什么是systemtap假如现在有这么一个需求:需要获取正在运行的 Linux 系统的信息,如我想知道系统什么时候发生系统调用,发生的是什么系统调用等这些信息,有什么解决方案呢?最原始的方法是,找到内核系统调用的代码,加上我们需要获得信息的代码、重新编译内核、安装、选择我们新编译的内核重启。这种做法对于内核开发人员简直是梦魇,因为一遍做下来至少得需要1个多小时,不仅破坏了原有内核代码,而且如果换了一个需求又得重新做一遍上面的工作。所以,这种调试内核的方法效率是极其底下 阅读全文
posted @ 2013-10-13 16:21 linyvxiang 阅读(309) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2485求最小生成树中最长的那个边 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define INF 0x0fffffff 5 int N,T; 6 int mat[502][502]; 7 int prim() 8 { 9 int start=0;10 bool visited[502]={false};11 int nearest[502];12 int max_len=-1;13 int min,pos;1.. 阅读全文
posted @ 2013-03-01 20:20 linyvxiang 阅读(158) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1789 1 #include <string.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #define INF 0x0fffffff 5 int mat[2002][2002]; 6 int N; 7 typedef struct Code { 8 char str[10]; 9 }Code;10 Code codes[2002];11 int calc(char *str1,char *str2)12 {13 char *p=str1,*q=str2 阅读全文
posted @ 2013-03-01 19:57 linyvxiang 阅读(214) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3278BFS 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <queue> 5 using namespace std; 6 int N,K; 7 bool visited_flag[100002]={false}; 8 bool check(int x) 9 {10 if(0<=x&&x<=100000)11 return true;12 return fal 阅读全文
posted @ 2013-03-01 14:34 linyvxiang 阅读(223) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1611简单并查集 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 int father[32002]; 5 void init(int n) 6 { 7 int i; 8 for(i=0;i<=n;i++) 9 father[i]=i;10 }11 int find_father(int child)12 {13 if(father[child]==child)14 return child;15 ... 阅读全文
posted @ 2013-03-01 09:24 linyvxiang 阅读(200) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3268不知道怎么回事,问题感觉今天读不懂题..题目要求求有向图中,除X外其余所有点到X的最短往返路径中,最长的那一个.FLOYD算法可以很容易的求出有向图中任意两点的最短路径,但是此题用FLOYD会超时.先用一次Dijkstra,求出从X到其余所有点的最短路径(这相当于回来时的长度),然后将这些路径记录,再将邻接矩阵转置,再用一次Dijkstra,将两次路径相加,找出最大的就可以了 1 #include <stdio.h> 2 #include <stdlib.h> 3 #define INF 0x0fffffff 阅读全文
posted @ 2013-02-28 14:24 linyvxiang 阅读(200) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1308并查集。1.不能有环,即只能有一个节点的入度为零 2.除根节点外,其余所有结点的入度必需为1 3.空树也是树 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <set> 5 #include <iterator> 6 using namespace std; 7 int father[10002]; 8 int degree[10002]={0}; 9 set<int 阅读全文
posted @ 2013-02-16 14:22 linyvxiang 阅读(295) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2488DFS+回溯,其实不用从所有节点开始搜索,因为要求输出的是字典序,所以只从A1开始搜索,能一次搜到便是存在,否则不存在。写完代码才意识到。另外注意字典序时,方向数组要写对。 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <stack> 5 using namespace std; 6 int c; 7 int n,p,q; 8 int start_x,start_y; 9 int t 阅读全文
posted @ 2013-02-14 16:04 linyvxiang 阅读(355) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2243BFS模板题 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <queue> 5 using namespace std; 6 char pos_start[3],pos_end[3]; 7 bool visited[20][20]={false}; 8 int dis[20][20]={0}; 9 typedef struct Node {10 int x,y;11 }Node;12 阅读全文
posted @ 2013-02-14 10:15 linyvxiang 阅读(161) 评论(0) 推荐(0) 编辑