题解:求环长比环边个数的最小值,即求min{Σw[i]/|S|},其中i∈S.这题一眼二分,然后可以把边的个数进行转化,假设存在Σw[i]/|S|<=k,则Σw[i]-k|S|<=0,即Σ(w[i]-k)<=0,然后就是表示图中存在负环,可以用spfa跑一下.不过图不保证连通,所以要从每个点分开跑SPFA,还要打标记,访问过的点不能再访问,复杂度O(n^2logw) #include<bits/stdc++.h> using namespace std; ; int n,m,…
题意 题目链接 Sol 暴力01分数规划可过 标算应该是这个 #include<bits/stdc++.h> #define Pair pair<int, double> #define MP(x, y) make_pair(x, y) #define fi first #define se second //#define int long long #define LL long long #define Fin(x) {freopen(#x".in",&q…
传送门 答案只保留了6位小数WA了两次233. 这就是一个简单的01分数规划. 直接二分答案,根据图中有没有负环存在进行调整. 注意二分边界. 另外dfs版spfa判负环真心快很多. 代码: #include<bits/stdc++.h> #define N 3005 #define M 10005 using namespace std; inline int read(){ int ans=0; char ch=getchar(); while(!isdigit(ch))ch=getcha…
Sightseeing Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9703 Accepted: 3299 Description Farmer John has decided to reward his cows for their hard work by taking them on a tour of the big city! The cows must decide how best to…
洛谷4951 地震 #include<iostream> #include<cstdio> #include<algorithm> #define go(i,a,b) for(register int i=a;i<=b;i++) #define ll long long #define db long double #define M 10001 #define N 401 #define inf 1e15 #define eps 1e-12 using name…