题目链接

线段树的逆过程,想了老一会,然后发现应该是包含区间对存在有影响,就不知怎么做了。。。然后尚大神,说,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. Sphinx的介绍和原理探索

    What/Sphinx是什么 定义 Sphinx是一个全文检索引擎. 特性 索引和性能优异 易于集成SQL和XML数据源,并可使用SphinxAPI.SphinxQL或者SphinxSE搜索接口 易于 ...

  2. Delphi面向对象的属性

    可以把属性看成是能对类中的数据进行修改和执行代码的特殊的辅助域.对于组件来说,属性就是列在Object Inspector窗口的内容.下面的例子定义了一个有属性的简单对象 TMyObject = cl ...

  3. Pyqt QSplashScreen启动画面

    多大数应用程序启动时都会在程序完全启动时显示一个启动画面,在程序完全启动后消失.程序启动画面可以显示一些有关产品的信息,让用户在等待程序启动的同时了解有关产品的功能,也是一个宣传的方式.QSplash ...

  4. python中的Iterable, Iterator,生成器概念

    https://nychent.github.io/articles/2016-05/about-generator.cn 这个深刻 谈起Generator, 与之相关的的概念有 - {list, s ...

  5. 【131031】struts 1 中 <html:form>

    <DIV>来看看 使用 ActionForm 这个主题,当时使用了一个静态表单网页:<BR>* form.htm<BR><BR><BR>&l ...

  6. 让用VS2012/VS2013编写的程序在XP中顺利运行

    转自:http://blog.csdn.net/asanscape/article/details/38752655/ 微软为了推销自家平台,默认配置下VS2012和VS2013编写的应用程序只能在V ...

  7. ios 数据类型转换 UIImage转换为NSData NSData转换为NSString

    1.UIImage转换为NSData NSData *data;if (UIImagePNGRepresentation(image) == nil) { data = UIImageJPEGRepr ...

  8. windowsapi

    内核相关的在:kernel.dll,提供内存管理.进程管理.进程调度.线程管理等等用户相关的在:user32.dll,提供执行用户界面相关的接口界面相关的在:gdi32.dll,提供画图相关的接口

  9. phpexecel 导入导出,格式

    1.日期时间合并到c中 =a1 &b1 或 =a1 + b1 这些都是运算符 2.此时c1的值是这条公式,而并不是公式运算的结果 复制c,粘贴到d,选择粘贴值 3.此时c是时间日期格式的,如需 ...

  10. 临时变量不能作为非const类型引用形参的实参

    摘要:     非const 引用形参只能与完全同类型的非const对象关联.      具体含义为:(1)不能用const类型的对象传递给非const引用形参:                  ( ...