Bzoj 3265 Volunteers recruit Enhanced simplex

Source: Internet
Author: User

Topic: Same as 1061 but the range of work for each type of volunteer is multi-segment

Is this a card network stream? Unknown

Anyway, to change the 1061 slightly to be able to go through--

#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include < algorithm> #define INF 1e10#define EPS 1e-7using namespace Std;int m,n;namespace linear_programming{double A[10100][ 1010],b[10100],c[1010],v;void Pivot (int l,int e) {int i,j;b[l]/=a[l][e];for (i=1;i<=n;i++) if (i!=e) a[l][i]/=a[l][e ]; A[l][e]=1/a[l][e];for (i=1;i<=m;i++) if (I!=l&&fabs (A[i][e]) >eps) {b[i]-=a[i][e]*b[l];for (j=1;j<= n;j++) if (j!=e) a[i][j]-=a[i][e]*a[l][j]; A[i][e]=-a[i][e]*a[l][e];} V+=c[e]*b[l];for (i=1;i<=n;i++) if (i!=e) c[i]-=c[e]*a[l][i];c[e]=-c[e]*a[l][e];} Double Simplex () {int I,l,e;while (1) {for (i=1;i<=n;i++) if (c[i]>eps) break;if ((e=i) ==n+1) return v;double temp= Inf;for (i=1;i<=m;i++) if (a[i][e]>eps && b[i]/a[i][e]<temp) temp=b[i]/a[i][e],l=i;if (Temp==INF) return INF; Pivot (l,e);}}} int main () {using namespace Linear_programming;int i,j,k,x,y;cin>>n>>m;for (i=1;i<=n;i++) scanf ("%lf", &c[i]); for (i=1;i<=m;i++) {scanf ("%d", &k); for (j=1;j<=k;j++) {scanf ("%d%d ", &x,&y); for (; x<=y;x++) a[i][x]+=1.0;} scanf ("%lf", &b[i]);} Double Ans=simplex ();p rintf ("%d\n", int (ans+0.5)); return 0;}


Bzoj 3265 Volunteers recruit Enhanced simplex

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.