Codeforces Round #331 (Div. 2) C. Wilbur and Points

Source: Internet
Author: User

Title Explanation: N Point pairs, n number, require to find out if there is an increase sequence to meet the answer, and output.

(Set rule: if (x, y) is in the collection, then (0,0) to (X,y-1), (X-1,y) is also in the collection

Input time is also)

First of all, how violence comes, we first classify n point pairs (based on the difference), and then each class is sorted from small to large. Then the current solution is to fill n number at a time, because the small must be filled in front of the large, otherwise it will not conform to the definition of the set.

Then judge, because the data points do not have a mutation, as long as the strict sense is not larger than the previous number, because it is a continuous data segment.

#include <cstdio>#include<algorithm>#include<cmath>#include<map>#include<iostream>#include<vector>#include<cstring>#include<queue>#include<string>using namespacestd;intN;structnode1{intX,y,c;} a[100005];intf[200005];intc[100005];vector<int> g[200005];intans[100005];BOOLCMP1 (Const intXxConst intyy) {    if(a[xx].x<a[yy].x)return 1; return 0;}intMain () {//freopen ("Input.txt", "R", stdin);scanf"%d",&N);  for(intI=0; i<n;i++) {scanf ("%d%d",&a[i].x,&a[i].y); A[I].C=a[i].y-a[i].x; G[A[I].C+100000].push_back (i); }    for(intI=0; i<=200002; i++) sort (G[i].begin (), G[i].end (), CMP1); intT; intflag=1;  for(intI=0; i<n;i++) {scanf ("%d",&t); C[i]=T; if(flag) {if(f[t+100000]==g[t+100000].size ()) {flag=0;  Break; } Ans[i]=g[t+100000][f[t+100000]]; F[t+100000]++;} }   if(!flag) {printf ("no\n"); return 0; }   Else   {       for(intI=1; i<n;i++)      {          intt1=a[ans[i]].x; intT2=a[ans[i]].y; intt3=a[ans[i-1]].x; intt4=a[ans[i-1]].y; if((T3&GT;T1&AMP;&AMP;T4&GT;=T2) | | ((t3>=t1&&t4>T2)))  {printf ("no\n"); return 0; }} printf ("yes\n");  for(intI=0; i<n;i++) printf ("%d%d\n", A[ANS[I]].X,A[ANS[I]].Y); }}

Codeforces Round #331 (Div. 2) C. Wilbur and Points

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.