zoukankan      html  css  js  c++  java
  • CodeForces Round 275 B

    We'll call an array of n non-negative integers a[1], a[2], ..., a[ninteresting, if it meets m constraints. The i-th of the m constraints consists of three integers liriqi (1 ≤ li ≤ ri ≤ n) meaning that value  should be equal to qi.

    Your task is to find any interesting array of n elements or state that such array doesn't exist.

    Expression x&y means the bitwise AND of numbers x and y. In programming languages C++, Java and Python this operation is represented as "&", in Pascal — as "and".

    Input

    The first line contains two integers nm (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits.

    Each of the next m lines contains three integers liriqi (1 ≤ li ≤ ri ≤ n0 ≤ qi < 230) describing the i-th limit.

    Output

    If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n](0 ≤ a[i] < 230) decribing the interesting array. If there are multiple answers, print any of them.

    If the interesting array doesn't exist, print "NO" (without the quotes) in the single line.

    题意为,有一个数组,告诉你一些区间的 & 值,问你是否存在这样的数组,存在输出一组

    解法CF上面有题解,我就不说咯

    总结一下这个题学到的东西:

    1,本来以为区间更改用线段树实现会很快,这次知道如果不是边改便询问的话,有一个更好的方法。

    2,原来&也是满足线段树处理的,以前一直不敢用,这次涨见识了

  • 相关阅读:
    辅助随笔:因知识点不足暂时错过的题目
    NOIP2019翻车前写(and 抄)过的代码
    NOIP2019翻车前计划以及日记
    Luogu P3706 [SDOI2017]硬币游戏
    Luogu P5296 [北京省选集训2019]生成树计数
    Luogu P3307 [SDOI2013]项链
    Gaussian整数
    Problem. S
    LOJ6696 复读机 加强版
    数据库约束
  • 原文地址:https://www.cnblogs.com/chensunrise/p/4095951.html
Copyright © 2011-2022 走看看