代码: struct NODE{ int to; int nxt; int c; }node[MM];//链式向前星 ; void add(int a,int b,int c){ node[lcnt].to=b; node[lcnt].c=c; node[lcnt].nxt=head[a]; head[a]=lcnt++; } 显示神奇代码 1.使用结构体构建链式向前星的容器 链式向前星本质上是使用链表存边,一条链表代表着一个点发出的所有边.所以一个这个结构体代表着这条链表中的一项 struct…
题目: A 国有 n 座城市,n−1 条双向道路将这些城市连接了起来,任何两个城市都可以通过道路互通. 某日,A 国爆发了丧尸危机,所有的幸存者现在都聚集到了 A 国的首都(首都是编号为 1 的城市).而其它城市的丧尸会时不时地向首都发起进攻. 为了抵御丧尸的攻击,幸存者在 A 国的每座城市都修建了防御工事.编号为 i 的城市,其防御工事强度为 di. 当一只丧尸决定进攻首都时,它会从某城市 u(u≠1) 沿经过道路数量最少的路径前往首都.沿途,这只丧尸会试图突破当地的防御工事. 对于某座防御工…
Silver Cow Party Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12674   Accepted: 5651 Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X …
这道模版用到了链式向前星表示法: struct node { int v,next; }edge[]; void add(int x,int y) { edge[++cnt].next=heads[x]; edge[cnt].v = y; heads[x]=cnt; return ; } 有地方写错了,应该是i=edge[i].next 输入:一个图有向图.输出:它每个强连通分量. input: 6 8 1 3 1 2 2 4 3 4 3 5 4 6 4 1 5 6 output: 6 5 3…
Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 19881   Accepted: 7114 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and pe…
1218: 奇奇与变形金刚 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 130  Solved: 37[Submit][Status][Web Board] Description 奇奇 gigi     奇奇口头禅:别人的失败就是我的快乐! 星座:处女座 生日:8月25日 血型:不明 年龄:2岁 生肖:鸡 身高:120公分 体重:149公斤   职业:机器人 兴趣:周游世界 宠物:变形金刚 最喜欢:充电 最讨厌:拔掉它的电源插头 偶像:科学怪人…
1.数据结构-链式队列的实现-C语言 typedef struct QNode { int data; struct QNode *next; }QNode,*QueuePtr; typedef struct { QueuePtr _front; //头指针 QueuePtr _rear; //尾指针 } LinkQueue; //构造空队列---1 void InitQueue(LinkQueue* Q); //队列的销毁---2 void DestroyQueue(LinkQueue* Q)…
链式哈希表的接口定义 关于哈希表与链式哈希表的描述可以参阅:http://www.cnblogs.com/idreamo/p/7990860.html 链式哈希表的操作与属性有:初始化.销毁.插入元素.删除元素.查找元素.获取哈希表中无数的个数. chtbl_init int cltbl_init(CHTbl *htbl, int buckts, int (*h)(const void *key), int (*match)(const void *key1,const void *key2),…
用链表搭建的栈与队列相对简单,队列的特点是先进先出,不啰嗦了,由于代码比较简单,相信光顾的人不会太多,下面直接贴代码. 头文件 #ifndef QUEUELI_H #define QUEUELI_H template<class T> class Queue { public: Queue(); ~Queue(); bool isEmpty() const; const T & getFront() const; void enqueue(const T& x); T dequ…
#include "string.h" #include "ctype.h" #include "stdio.h" #include "stdlib.h" #include "io.h" #include "math.h" #include "time.h" #define OK 1 #define ERROR 0 #define TRUE 1 #define FAL…