Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 17538   Accepted: 5721 Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate th…
昨天的题太水了,堆优化跑的不爽,今天换了一个题,1000000个点,1000000条边= = 试一试邻接表 写的过程中遇到了一些问题,由于习惯于把数据结构封装在 struct 里,结果 int [1000000] 导致 struct 爆栈,此问题亟待解决.. 实力碾压SPFA 2500 ms,有图为证 #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #d…
题目链接: http://poj.org/problem?id=3687 要逆向建图,输入的时候要判重边,找入度为0的点的时候要从大到小循环,尽量让编号大的先入栈,输出的时候注意按编号的顺序输出重量,不是按重量大小输出编号.. 题目确实很简单,但是感觉很经典. #include <stdio.h> #include <string.h> #include <stack> using namespace std; ][], vis[]; ], weight[]; stac…
#include <iostream> #include <queue> using namespace std; #define MaxVertexNum 10 typedef int Vertex; typedef int WeightType; typedef char DataType; bool Visited[MaxVertexNum] = { false }; //边的定义 typedef struct ENode { Vertex V1, V2; //有向边<…
逃生 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description 糟糕的事情发生啦,现在大家都忙着逃命.但是逃命的通道很窄,大家只能排成一行. 现在有n个人,从1标号到n.同时有一些奇怪的约束条件,每个都形如:a必须在b之前.同时,社会是不平等的,这些人有的穷有的富.1号最富,2号第二富,以此类推.有钱人就贿赂负责人,所以他们有一些好处. 负责人现在…
FDNY to the Rescue! Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2368   Accepted: 721 Description The Fire Department of New York (FDNY) has always been proud of their response time to fires in New York City, but they want to make the…
Invitation Cards Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 27200   Accepted: 9022 Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They wan…
图通常有两种表示方法: 邻接矩阵 和 邻接表 对于稀疏的图,邻接表表示能够极大地节省空间. 以下是图的数据结构的主要部分: struct Vertex{ ElementType element; //节点的名字 Edge *next;   //所包含的边组成的单链表的头指针 }; struct Edge{ int adj;  //节点的标号(0-number of nodes) Edge *next; }; 注意,实际应用中,节点都有名字,而不是数字,所以我们需要提供从名字到标号的映射. 最简单…
#include <iostream> #include <string> #include <queue> using namespace std; //表结点 typedef struct ArcNode{ int adjvex;//该弧所指向的顶点的位置 ArcNode *nextarc;//指向下一条弧的指针 }ArcNode; //头结点 typedef struct VNode{ string data;//顶点信息 ArcNode* firstarc;//…
#include <cstdio> #include <algorithm> #include <cstring> #include <queue> #define inf 0x3f3f3f3f #define N 35 #define maxn 5000 #define mod 1000000007 #define ll long long using namespace std; int n,m,q,cte; ]; ,,,}; ,,,-}; struct…