4443: [Scoi2015] little bald Play Matrix | Two-point ANSWER | Hungary

Source: Internet
Author: User

The K Large as the first K Small Variety wa ...
The K Big is the first ? K + 1 Small, so you can have a happy two-point answer
The two-point answer finds the coordinates of the position of the number that are smaller than the current answer, and determines if it is possible to select one that satisfies the same column in the same row ? K + 1 Number, and then you can happily run Hungary, for a coordinate x , Y ) If you meet a[x][y]≤ The current answer, the first x Line to section y Column and then run Hungary to determine whether the maximum match is greater than ? K + 1
Hungary really runs fast, and then it snaps into Rank1 Qaq

#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <vector>#include <cmath>#include <queue>#include <set>#include <map>#define LL Long Long#define N 1000001using namespace STD;intSC () {intI=0, f=1;CharC=getchar (); while(c>' 9 '|| c<' 0 '){if(c=='-') f=-1; C=getchar ();} while(c>=' 0 '&&c<=' 9 ') i=i*Ten+c-' 0 ', C=getchar ();returnI*f;}inta[255][255];intHead[n],nxt[n],lst[n],tim[n],from[n];intN,m,tot,mx,ti,k;voidInsertintXintY) {Lst[++tot]=y;nxt[tot]=head[x];head[x]=tot;}BOOLHungary (intx) { for(intI=head[x];i;i=nxt[i])if(Tim[lst[i]]!=ti) {Tim[lst[i]]=ti;if(!from[lst[i]]| | Hungary (From[lst[i])) {from[lst[i]]=x;return 1; }        }return 0;}BOOLJudintx) {intans=0; tot=0; for(intI=1; i<=n;i++) head[i]=0; for(intI=1; i<=m;i++) from[i]=0; for(intI=1; i<=n;i++) for(intj=1; j<=m;j++)if(a[i][j]<=x) Insert (I,J); for(intI=1; i<=n;i++) ti++,ans+=hungary (i);returnAns>=k;}intMain () {N=SC (); M=sc (), K=SC (); k=n-k+1; for(intI=1; i<=n;i++) for(intj=1; j<=m;j++) Mx=max (MX,A[I][J]=SC ());intL=1, R=MX; while(L!=R) {intMid=l+r>>1;if(Jud (mid)) R=mid;ElseL=mid+1; }cout<<l;return 0;}

4443: [Scoi2015] little bald Play Matrix | Two-point ANSWER | Hungary

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.