BZOJ4143 [Amppz2014]the Lawyer

Source: Internet
Author: User

Descriptionbyteasar to make a plan for the meeting of M days, there are N sessions, the first session begins in the first d[i] days of a[i] seconds, and ends in the b[i] second of the day of the first d[i]. For each day, please find out the two sessions of the day i,j, so that they do not conflict, i.e. there is not a number k while satisfying a[i]<=k<=b[i] and a[j]<=k<=b[j].

The first line of input contains two positive integers n,m (2<=n<=500000,1<=m<=20), representing the number of fields and days of the meeting. Next n rows, each row contains three positive integers a[i],b[i],d[i] (1<=a[i]<b[i]<=80000000,1<=d[i]<=m), describing a meeting.

Output M row. Line I output the answer to day I, if no solution, output nie, otherwise output tak, and then output this day to participate in the number of two sessions, if there are multiple sets of solutions, output any group.

Sample Input6 3
3 5 1
2 4 2
1 8 1
6 7 3
3 5 2
7 1Sample OutputTAK 1 6
NIE
NIE

Is this really a question on the Bzoj?
With the adjacent edge will be a daily meeting string up, because any one scheme, sweep the left end of the maximum value, the right end of the minimum value, can be sentenced.

#include <cstdio>#include<cctype>#include<queue>#include<cstring>#include<algorithm>#defineRep (i,s,t) for (int i=s;i<=t;i++)#defineren for (int i=first[x];i!=-1;i=next[i])using namespaceStd;inlineintRead () {intx=0, f=1;CharC=GetChar ();  for(;! IsDigit (c); C=getchar ())if(c=='-') f=-1;  for(; IsDigit (c); C=getchar ()) x=x*Ten+c-'0'; returnx*F;}Const intmaxn=500010;structConference {ints,t;} A[MAXN];intfirst[ +],NEXT[MAXN],E,NUM[MAXN];voidADD (intXintv) {num[++e]=v;next[e]=first[x];first[x]=e;}intn,m;intMain () {n=read (); m=read (); Rep (I,1, n) a[i].s=read (), a[i].t=read (), ADD (read (), i); Rep (I,1, M) {        intA=num[first[i]],b=a,cnt=0;  for(intj=first[i];j;j=Next[j]) {            if(A[NUM[J]].S&GT;A[A].S) a=Num[j]; if(a[num[j]].t<a[b].t) b=Num[j]; CNT++; }        if(cnt<2|| A[A].S&LT;=A[B].T) puts ("NIE"); Elseprintf"TAK%d%d\n", A, b); }    return 0;}
View Code

BZOJ4143 [Amppz2014]the Lawyer

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.