题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意: 有一个 n 个点无向图,再给你 m 对顶点, 代表着这 m 对顶点之间没有边, 除此之外每两个点之间都有一条边, 且权值为 1.然后还有一个源点 S, 让你计算源点到其他各点之间的最短距离,如果不存在则输出 -1.也就是说让你在所给的图的补图上求源点到其他各点的最短路径. 思路: 补图上求最短路径算是比较经典的题.在这里所求的最短路其实并不需要用到 dijkstra 之类的算法,由于每…
http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意: 在补图中求s到其余各个点的最短路. 思路:因为这道题目每条边的距离都是1,所以可以直接用bfs来做. 处理的方法是开两个集合,一个存储当前顶点可以到达的点,另一个存储当前顶点不能到达的点.如果可以到达,那肯定由该顶点到达是最短的,如果不能,那就留着下一次再判. #include<iostream> #include<algorithm> #include<cstring>…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 689    Accepted Submission(s): 238 Problem Description In graph theory, the complement of a graph G is a graph H on the same vertic…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem Description In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1520    Accepted Submission(s): 537 Problem Description In graph theory, the complement of a graph G is a graph H on the same verti…
Sparse Graph Problem Description   In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are notadjacent in G. Now you are given an undirected graph G of N…
BFS+链表 代码改自某博客 #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string> #include<map> #include<set> #include<vector> #include<queue> using nam…
Problem Description In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in G. Now you are given an undirected graph G of N nodes and M b…
Marriage Match IV 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/Q Description Do not sincere non-interference. Like that show, now starvae also take part in a show, but it take place between city A and B. Starvae is in city A and girls a…
题意:给你n个点m条边形成一个无向图,问你求出给定点在此图的补图上到每个点距离的最小值,每条边距离为1 补图:完全图减去原图 完全图:每两个点都相连的图 其实就是一个有技巧的bfs,我们可以看到虽然点很多但边很少,就使用vector存下每个点在原图中可以到达其他的哪些点,再使用bfs寻找此时起点可以到的其他点(每个距离都是1,所以越早到距离越短),接着更新起点继续查找:我们需要使用数组记录此时起点不能到的一些点(就是vector中原图起点可以到的点),但每次通过起点判断其他所有的点会超时,因此我…
1.HDU 5876  Sparse Graph 2.总结:好题,把STL都过了一遍 题意:n个点组成的完全图,删去m条边,求点s到其余n-1个点的最短距离. 思路:把点分为两个集合,A为所有没有到达过的点,B为当前不可到达的点,每次拓展A中可到过的点加入队列. #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #inc…
http://acm.hdu.edu.cn/showproblem.php?pid=5876 Sparse Graph Problem Description   In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in…
In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in G. Now you are given an undirected graph G of N nodes and M bidirectional edges o…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 928    Accepted Submission(s): 312 Problem Description In graph theory, the complement of a graph G is a graph H on the same verti…
题目大意: 给出一个图和起点S,求补图中S到其他点的最短距离. http://acm.hdu.edu.cn/showproblem.php?pid=5876 我自己的垃圾做法: 用线段树来维护dijkstra的dis数组.每次取出dis最小的点来更新其他点. 假设x连出去的边是y1 < y2 < y3 ... < yk.  那么对于dis[1, y1 - 1] [y1 + 1, y2 - 1] [y2 + 1, y3 - 1]...这些区间做区间取min操作. 比较容易出错的的地方是每次…
---恢复内容开始--- Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2590    Accepted Submission(s): 902 Problem Description In graph theory, the complement of a graph G is a graph H on t…
题目链接:hdu5876 Sparse Graph 详见代码.. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<vector> #include<set> using namespace std; ; const int inf = 0x3f3f3f3f; int n, m; vector<vector<int…
题目链接:hdu_5876_Sparse Graph 附上叉姐的题解: 1009 Sparse Graph [by ftiasch] 题意:n 个点的无向完全图中删除 m 条边,问点 s 到其他点的最短路长度. 题解: 补图上的 BFS 是非常经典的问题.一般的做法是用链表(或者偷懒用 std::set)维护还没 BFS 过的点.当要扩展点 u 的时候,遍历一次还没访问过的点 v,如果 uv 没边,那么将 v 入队.否则将 v 留在未扩展点中. 很明显,后者只会发生 m 次,前者只会发生 n 次…
Sightseeing Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1023    Accepted Submission(s): 444 Problem Description Tour operator Your Personal Holiday organises guided bus trips across the Ben…
MATLAB中求矩阵非零元的坐标: 方法1: index=find(a); [i,j]=ind2sub(size(a),index); disp([i,j]) 方法2: [i,j]=find(a>0|a<0) %列出所有非零元的坐标 [i,j]=find(a==k) %找出等于k值的矩阵元素的坐标 所用函数简介: IND2SUB Multiple subscripts from linear index. IND2SUB is used to determine the equivalent…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3760 思路:首先是建反图,从点n开始做spfa求出n到各点的最短路,然后从1点开始搜最小序列,对于边(u,v),若dist[u]==dist[v]+1,则要将当前的序号加入当前队列中,然后就是对于那些序号相同点的都要加入当前队列,还要判一下重.至于为什么要建反图从n点开始求最短路,因为在搜最小序列的时候要保证一定能搜到n点. #pragma comment(linker, "/STACK:10240…
Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 2487    Accepted Submission(s): 386 Problem Description In graph theory, the complement of a graph G is a graph H on the same vertices such tha…
SQL SERVER中求上月.本月和下月的第一天和最后一天   1.上月的第一天 SELECT CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) 2.上月的最后一天 SELECT CONVERT(CHAR(10),DATEADD(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()),0)),111)+' 23:59:59' 3.本月的第一天 SELECT…
支付宝微信O2O大战,WiFi广告在夹缝中求生存 来自工信部的数据显示,截至2013年底,中国智能手机的保有量已经达到5.8亿台.国内平均有46%的时间选择WiFi上网. 商用WiFi已经成为了移动互联网的一大流量入口.因此,WiFi成为了巨头争夺线下的新战场. 有消息称,继微信推出企鹅路由器后,支付宝也迅速回应,会给用户在公共WiFi覆盖区域推送一条消息,用户点击该消息后会自动连接上网. 除了它们,许多互联网公司也推出了相应的WiFi服务,其中,成都无线天继率先推出微信一键关注上网以后,领先业…
HDU 3065 病毒侵袭持续中 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description - 题目描述 小t非常感谢大家帮忙解决了他的上一个问题.然而病毒侵袭持续中.在小t的不懈努力下,他发现了网路中的“万恶之源”.这是一个庞大的病毒网站,他有着好多好多的病毒,但是这个网站包含的病毒很奇怪,这些病毒的特征码很短,而且只包含“英文大写字符”.当然小…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem Description In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if…
夹缝中求生存 前言:在上一篇随笔中,以163个人邮箱作为发送邮箱地址,当收件邮箱为QQ邮箱时,极有可能会被直接扔进邮件垃圾箱里,为了解决这个问题,申请注册企业邮箱,可以减少发出的邮件被当作垃圾邮件的可能性.本文以腾讯企业邮箱为例. 既然是企业邮箱,首先前提是你得有一个自己的域名.然后就可以去申请免费的腾讯企业邮箱账户,传送门. 按照免费腾讯企业邮箱的申请要求,验证域名所有权后在域名提供商处设置好MX解析.下图是我在阿里云的域名设置. 设置好网站邮箱管理员后,可添加一个成员账户,比如命名为serv…
HDU 6321 Dynamic Graph Matching (状压DP) Problem C. Dynamic Graph Matching Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 1796 Accepted Submission(s): 731 Problem Description In the mathematical…
初学java的时候接触的%这个符号 百分号? 求余? 取模? 我只知道不是百分号,好像是求余,听别人那叫求模运算符,跟求余一样,于是我便信了. 思考之后开始迷糊,然后经过多次考证得到以下结论. 首先,%是求余的意思,不是求模的意思.求模不完全等于求余. 首先我们遵守公式: a = b * q + r; 这里的a是被除数,b是除数,q是商,r是余数也可以是模. q= a/b 且 |r| < |b| 于是得到: r = a – (a/b)*b; r的求值公式都是这样,那么求余和求模的区别在哪呢? 1…
在C语言中求字符串的长度,可以使用sizeof()函数和strlen()函数,后者需要引入string.h (#include <string.h>) 因为C语言字符串是以 \0 结尾表示结束的,如: char str1[] = {'h','e','l','l','o','\0'}; 使用sizeof(str1) 结果为:6,因为包括 \0; 使用strln(str1)结果为:5,不包括 \0, 所以只求字符串中内容的长度,就使用strlen()函数 另: sizeof()函数,既可以用来计算…