Problem
对于一个n个顶点的有向强连通图,求.
Solution
对于,可以用spfa或dijstra求出单源最短路,对于
,可以将边反向后求最短路。
本人用的是spfa,要注意手搓循环队列的时候,不是front < rear,而是front != rear,偷偷告诉你我不太会写dijstra
同时,最好不写双份代码,不便于调试。
Code
#include<cstdio>
#include<cstring>
#define MAXN 1005
#define MAXM 100010
#define INF 999999999
using namespace std;
int read(){
int res = 0, ch = getchar();
bool flag = false;
while((ch < '0' || ch > '9') && ch != '-') c