人老了就比较懒,故意挑了到看起来很和蔼的题目做,然后套个spfa和dinic的模板WA了5发,人老了,可能不适合这种刺激的竞技运动了…… 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2760 Description Given a weighted directed graph, we define the shortest path as the path who has the smallest leng…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1760 题意:给定一个带权有向图 G=(V, E)和源点 s.汇点 t,问 s-t 边不相交最短路最多有几 条.(1 <= N <= 100) 思路:分别从源点和汇点作一次 Dijkstra,可是流量网络仅仅增加 满足dis[i] + ma[i][j] + (dis[t]-dis[i])==dis[t]的边(u, v)(这样便保证网络中的随意一条 s-t 路都 是最…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1760 Given a weighted directed graph, we define the shortest path as the path who has the smallest length among all the path connecting the source vertex to the target vertex. And if two…
Description Given a weighted directed graph, we define the shortest path as the path who has the smallest length among all the path connecting the source vertex to the target vertex. And if two path is said to be non-overlapping, it means that the tw…
不重叠最短路计数. 先弗洛伊德求一遍两两距离(其实spfa或者迪杰斯特拉会更快但是没必要懒得写),然后设dis为st最短距离,把满足a[s][u]+b[u][v]+a[v][t]==dis的边(u,v)连流量为1的边,表示只能走一次.注意这里a数组是弗洛伊德之后的,b是边的原长,然后跑一边最大流即可. 注意两点 特判掉s不能到达t的情况,直接输出0 弗洛伊德之前把所有数组中形如[i][i]的全部置为0,输入可能有trick #include<iostream> #include<cstd…
[题意]给定一个N(N<=100)个节点的有向图,求不相交的最短路径个数(两条路径没有公共边). [思路]先用Floyd求出最短路,把最短路上的边加到网络流中,这样就保证了从s->t的一个流一定是一条最短路,也就保证了网络流建模的正确性. [找最短路上的边] 满足最优子结构的性质:(i, j)是最短路上的边,当且仅当dist[s][i] + edge[i][j] + dist[j][t] = dist[s][t]. 一开始想的是满足dist[s][j] = dist[s][i] + edge[…
题目大意:给定一个带权有向图G=(V, E)和源点s.汇点t,问s-t边不相交最短路最多有几条.(1 <= N <= 100) 题解:从源点汇点各跑一次Dij,然后对于每一条边(u,v)如果保证d[s][u]+d[u][v]+d[v][t]==d[s][t]就加边1,然后跑最大流就好. 然而为什么不能是d[s][u]+d[u][t]==d[s][t]呢?我给个反例好了. 比如看这个图:(这是我用Gve写的最丑的图了将就看吧) digraph G{ ->[label="]; -&…
Shortest Path Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u SubmitStatus Description When YY was a boy and LMY was a girl, they trained for NOI (National Olympiad in Informatics) in GD team. One day, GD team's coach, Prof. G…
考试的T3,拿暴力+剪枝卡过去了. 没想到 CF 上也能过 ~ code: #include <bits/stdc++.h> #define N 100004 #define LL long long #define inf 1000000000000000 using namespace std; int go[N]; namespace IO { char *p1, *p2, buf[100000]; #define nc() (p1 == p2 && (p2 = (p1…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3781 Time Limit: 2 Seconds      Memory Limit: 65536 KB Leo has a grid with N rows and M columns. All cells are painted with either black or white initially. Two cells A and B are calle…