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>T1&&T4>=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