思路:设dis[i]为从0点到第i点的序列总和.那么对于A B gt k 来讲意思是dis[B+A]-dis[A]>k; 对于A B lt k来讲就是dis[B+A]-dis[A]<k;将两个不等式都化为 dis[A]-dis[B+A]<=-k-1; dis[A+B]-dis[A]<=k-1;那么就可以根据公式来建边了,用bellman_ford算法判断是否存在负圈就行了. #include<iostream> #include<cstdio> #inc…
King Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12056 Accepted: 4397 Description Once, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my child was a son and if only he was a sound kin…