水到家了
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Point{ int index, pos; Point(int index_ = 0, int pos_ = 0){ index = index_; pos = pos_; } bool operator < (const Point& a) const{ return pos < a.pos; } }; int main(){ int n,m, l,r; cin >> n >> m; vector<Point> points(n); for(int i = 0 ; i < n ; ++ i){ cin >> points[i].pos; points[i].index = i; } sort(points.begin(),points.end()); for(int i = 0 ; i < m; ++ i) cin >> l >> r; vector<int> res(n,0); for(int i = 0 ; i < n ; ++ i ){ if(i%2 == 0) res[points[i].index] =1; } cout<<res[0]; for(int i = 1 ; i <n ; ++ i ) cout<<" "<<res[i]; cout<<endl; }
Codeforces Round #245 (Div. 2) A - Points and Segments (easy)
时间: 2024-12-26 21:39:20