Test instructions: Given n points, m intervals, you need to apply blue or red to these points, so that the number of points in each interval of the red point and the number of points in blue is less than 1
Alas, the title of the title is marked with a easy= = The first time to do the point and the interval are sorted, simulated to do, but the wrong
Later found no matter what the interval, as long as the red and blue alternating coloring,
Must be able to satisfy the "the difference between the number of points in each interval and the number of blue dots is less than 1".
A bit like the last time I did the CF alternating output odd even that a question
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A -typedefLong LongLL; - Const intINF = (1<< -)-1; the Const intMod=1000000007; - Const intmaxn=1005; - - structnode{ + intx, y, z - } A[MAXN]; + A intCMP (node N1,node n2) { at if(n1.x!=n2.x)returnn1.x<n2.x; - returnn1.y<n2.y; - } - - intMain () { - intn,m; inscanf"%d%d",&n,&m); - for(intI=1; i<=n;i++){ toscanf"%d",&a[i].x); +a[i].y=i; -a[i].z=0; the } * $Sort (A +1, a+n+1, CMP);Panax Notoginseng - while(m--){ the intu,v; +Cin>>u>>v; A } the + for(intI=1; i<=n;i++){ - if(i%2) a[a[i].y].z=1; $ Elsea[a[i].y].z=0; $ } - - for(intI=1; i<=n;i++) theprintf"%d", a[i].z); - return 0;Wuyi}
View Code
Codeforces 430 A Points and segments (easy)