Codeforces Round #245 (Div. 2) A - Points and Segments (easy)

水到家了

#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

Codeforces Round #245 (Div. 2) A - Points and Segments (easy)的相关文章

Codeforces Round #501 (Div. 3) A Points in Segments

翻译 现在有一个数轴,上面会有\(M\)个点,标号为\(1\)到\(N\),现在给你在数轴上的条\(N\)线段的起始与终止的点,问哪几个点没有被这样线段覆盖,从小到大输出. 思路 签到题目.感觉几乎和一道题一样:校门外的树,撞题是很尴尬.思路差不多,即为开一个数组,全部赋值为\(0\),输入的线段的时候,将其起点与终点的全部的点赋值为\(1\),最后跑一下看看那些为\(0\)的点就完事了. Code #include<iostream> using namespace std; int boo

Codeforces Round #245 (Div. 1)——Tricky Function

l and dished out an assist in the Blackhawks' 5-3 win over the Nashville Predators.Shaw said just playing with the Blackhawks was enough motivation for him."Positive, I'm playing in the NHL," Shaw said after Sunday's win. "What can't you be

Codeforces Round #245 (Div. 2)

A Points and Segments (easy) 智商题,(智商捉急~) /*********************************************************** *分析:只要按Xi从小到大染成1010101010... , *1.0间隔的的序列就能保证对于任意区间[l, r]中1的个数和0的个数之差小于等于1. *注意:由于输入的Xi可能是无序的,所有要两次排序处理. *******************************************

Codeforces Round #245 (Div. 1)——Working out

题目链接 题意: 一个n*m的矩阵,每个方格有一个非负数,现在选择两条线路:一个左上到右下,一个左下到右上,且只能有一个公共点.求两个线路上数的最大值(公共点不算) 分析: 只有两种情况,dp即可.记两个线路为1和2,考虑一个公共点,1为左进右出,2为下进上出:1上进下出,2为左进右出 const int MAXN = 1005; int lu[MAXN][MAXN], ld[MAXN][MAXN]; int ru[MAXN][MAXN], rd[MAXN][MAXN]; int ipt[MAX

Codeforces Round #245 (Div. 1)——Xor-tree

题目链接 题意: 给一棵树n个节点,1为根节点.操作为,选定一个节点x,当前值取反,x的孙子,孙子的孙子...均取反 现在告诉初始时每个点的值和最后每个点的目标值,求操作次数最少时需要选择那些节点 (1?≤?n?≤?105) 分析: 深度浅的点一定是受影响最小的(根节点只受自己的影响),所以从根依次向下递推处理即可 const int MAXN = 110000; VI G[MAXN], ans; int now[MAXN], goal[MAXN]; void dfs(int u, int fa

Codeforces Round #245 (Div. 1)——Guess the Tree

本文出自:http://blog.csdn.net/svitter 实验环境:Myeclipse10 + tomcat7.0 有时间会写windows和linux下的tomcat配置,现在时间有限,暂且不写了..有些东西也是没有理解透彻. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <%@ page language="java" contentType="

Codeforces Round #245 (Div. 2) B - Balls Game

暴利搜索即可 #include <iostream> #include <vector> #include <iostream> using namespace std; int main(){ int n,k,x; cin >> n >> k >> x; vector<int> c(n); for(int i = 0 ; i < n; ++ i) cin >> c[i]; int ans = 0; fo

Codeforces Round #486 (Div. 3) D. Points and Powers of Two

Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvoeEx/contest/988/problem/D Description There are n distinct points on a coordinate line, the coordinate of i-th point equals to xi. Choose a subset of

Codeforces Round #245 (Div. 1) B. Working out (简单DP)

题目链接:http://codeforces.com/problemset/problem/429/B 给你一个矩阵,一个人从(1, 1) ->(n, m),只能向下或者向右: 一个人从(n, 1) ->(1, m),只能向上或者向右.必须有一个相遇点, 相遇点的值不能被取到, 问两个人能得到的最大路径和是多少? dp[i][j]:表示从一个点出发的最大值:先预处理从(1,1) (1,m) (n,1) (n,m)四个点出发的4个dp最大值.然后枚举所有的点,但是这个点不能在边缘,考虑枚举点不够