题目链接

线段树的逆过程,想了老一会,然后发现应该是包含区间对存在有影响,就不知怎么做了。。。然后尚大神,说,So easy,你要倒着来,然后再正着来,判断是不是合法就行了。然后我乱写了写,就过了。数据难道又水了。。。

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int p[],o[],ans[];
int t[],l[],r[],d[];
int main()
{
int n,m,i,j,flag,maxz;
scanf("%d%d",&n,&m);
for(i = ;i <= n;i ++)
p[i] = -;
for(i = ;i <= m;i ++)
{
scanf("%d%d%d%d",&t[i],&l[i],&r[i],&d[i]);
}
flag = ;
for(i = m;i >= ;i --)
{
if(t[i] == )
{
for(j = l[i];j <= r[i];j ++)
p[j] -= d[i];
}
else
{
for(j = l[i];j <= r[i];j ++)
{
if(o[j]&&p[j] < d[i]) continue;
p[j] = d[i];
o[j] = ;
}
}
}
for(i = ;i <= n;i ++)
ans[i] = p[i];
for(i = ;i <= m;i ++)
{
if(t[i] == )
{
for(j = l[i];j <= r[i];j ++)
p[j] += d[i];
}
else
{
maxz = -;
for(j = l[i];j <= r[i];j ++)
{
maxz = max(maxz,p[j]);
}
if(maxz != d[i]) flag = ;
}
}
if(flag)
printf("NO\n");
else
{
printf("YES\n");
for(i = ;i <= n;i ++)
{
if(i == )
printf("%d",ans[i]);
else
printf(" %d",ans[i]);
}
printf("\n");
}
return ;
}

Codeforces Round #210 (Div. 2) C. Levko and Array Recovery的更多相关文章

  1. Codeforces Round #210 (Div. 2) A. Levko and Table

    让对角线的元素为k就行 #include <iostream> using namespace std; int main() { int n,k; cin >> n > ...

  2. CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))

    题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发  问s1 出发的能不能先打到f 思路:最短路. 首先检测能不能赢 在更新的时候  如果对于一条边 ...

  3. Codeforces Round #210 (Div. 1).B

    经典的一道DP题. 题目明显是一道DP题,但是比赛的时候一个劲就在想怎么记录状态和转移.最后想到了一种n^3的方法,写了下,不出所料的超时了. 看了别人的代码才发现竟然是先二分然后再进行DP,像这种思 ...

  4. Codeforces Round #179 (Div. 1) A. Greg and Array 离线区间修改

    A. Greg and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/295/pro ...

  5. Codeforces Round #331 (Div. 2) B. Wilbur and Array 水题

    B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  6. Codeforces Round #258 (Div. 2) B. Sort the Array

    题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把 ...

  7. Codeforces Round #510 (Div. 2) D. Petya and Array(离散化+反向树状数组)

    http://codeforces.com/contest/1042/problem/D 题意 给一个数组n个元素,求有多少个连续的子序列的和<t (1<=n<=200000,abs ...

  8. Codeforces Round #374 (Div. 2) D. Maxim and Array 贪心

    D. Maxim and Array 题目连接: http://codeforces.com/contest/721/problem/D Description Recently Maxim has ...

  9. Codeforces Round #373 (Div. 2) E. Sasha and Array 线段树维护矩阵

    E. Sasha and Array 题目连接: http://codeforces.com/contest/719/problem/E Description Sasha has an array ...

随机推荐

  1. 为什么是 n(n+1)/2 ?

    n(n+1)/2是一个数列的元素两两运算后的不重复结果数.如图: 假如数列a = 1,2,3....n.那么该数列内的元素两两相乘,则会构建出上图中的表格,这个表格应该有n x n 个元素. 用程序写 ...

  2. PS 零基础训练1

    背景色:Alt + Del 前景色:Ctrl + Del 快捷键: 更换工具栏里的第二项:Shift + W or Shift + C  ... 缩放:Ctrl + = or Ctrl + - 工具笔 ...

  3. javascript的笔记精简版

    在写javascript的代码时一定要用单引号或者双引号括起来,不带引号的话就以字符串来处理 在javascript里面不能以纯数字或者click命名函数或者变量 要想修改标签的属性,在html里面怎 ...

  4. 【jQuery 区别】.click()和$(document).on("click","指定的元素",function(){});的区别

    给出以下的代码展示: //绑定 下一页 的点击事件 $("a[aria-label='Next']").click(function(){ $("a[aria-label ...

  5. 如何将Android Studio项目提交(更新)到github

    转载:http://blog.csdn.net/jinrall/article/details/45787477 前言 在写这篇文章之前首先我假设你已经安装了Android Studio 并已经会用A ...

  6. Loadrunner中动态添加虚拟用户

    添加的虚拟用户会立马开始执行: 场景组的两种模式: Vuser组模式: Vuser组模式中,对于压力负载机是不能同时添加多个 但是我们可以在一个脚本里通过多次添加Vuser,每次添加30个Vuser, ...

  7. LoadRunner中截取字符串

    LoadRunner中截取字符串 /*strchr和strrchr的区别*/ char *strTest1="citms citms"; char *strTest2,*strTe ...

  8. hdu 2669 Romantic

    Romantic Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  9. AOP静态代理解析1-标签解析

    AOP静态代理使用示例见Spring的LoadTimeWeaver(代码织入) Instrumentation使用示例见java.lang.instrument使用 AOP的静态代理主要是在虚拟机启动 ...

  10. nefu1118 最长上升子序列(LIS)

    discription:定义臻.排序数列如下:一个数列删去其中一个数后是从小到大排好序的,称这个数列为臻.排序数列.现在给你一个数列,判断它是否为臻.排序数列. intput:多组输入数据,每组有两行 ...