Codeforces Round #210 (Div. 2) C. Levko and Array Recovery
线段树的逆过程,想了老一会,然后发现应该是包含区间对存在有影响,就不知怎么做了。。。然后尚大神,说,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的更多相关文章
- Codeforces Round #210 (Div. 2) A. Levko and Table
让对角线的元素为k就行 #include <iostream> using namespace std; int main() { int n,k; cin >> n > ...
- CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))
题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发 问s1 出发的能不能先打到f 思路:最短路. 首先检测能不能赢 在更新的时候 如果对于一条边 ...
- Codeforces Round #210 (Div. 1).B
经典的一道DP题. 题目明显是一道DP题,但是比赛的时候一个劲就在想怎么记录状态和转移.最后想到了一种n^3的方法,写了下,不出所料的超时了. 看了别人的代码才发现竟然是先二分然后再进行DP,像这种思 ...
- 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 ...
- 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 ...
- Codeforces Round #258 (Div. 2) B. Sort the Array
题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把 ...
- Codeforces Round #510 (Div. 2) D. Petya and Array(离散化+反向树状数组)
http://codeforces.com/contest/1042/problem/D 题意 给一个数组n个元素,求有多少个连续的子序列的和<t (1<=n<=200000,abs ...
- Codeforces Round #374 (Div. 2) D. Maxim and Array 贪心
D. Maxim and Array 题目连接: http://codeforces.com/contest/721/problem/D Description Recently Maxim has ...
- 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 ...
随机推荐
- SVN 升级后出现You need to upgrade the working copy first.
今天将svn更新后,出现 svn: The working copy at 'E:\591woospace\kst_fashion_alipay_v1.2.0\src\com\kstapp\wansh ...
- Pyqt 屏幕截图工具
从Pyqt的examples中看到一段截图代码, (路径:examplas\desktop\screenshot.py) 所以想自己UI下界面,手动练习下 通过UI生成的: Screenshot.py ...
- C# 使用Conditional特性而不是#if条件编译
概述 #if/#endif 语句常用来基于同一份源码生成不同的编译结果,其中最常见的就是debug版和release版.但是这些工具在实际应用中并不是非常友好,因为它们容易被滥用,其代码页进而难以理解 ...
- Bootstrap 排版 笔记
Bootstrap 使用 Helvetica Neue. Helvetica. Arial 和 sans-serif 作为其默认的字体栈. 使用 Bootstrap 的排版特性,您可以创建标题.段落. ...
- ORA-1461 encountered when generating server alert SMG-3500
Doc ID 461911.1 Patch 6602742 Applies to: Oracle Database - Enterprise Edition - Version 10.2.0.3 an ...
- 设置SecureCRT会话的缓冲区大小
转自:http://blog.csdn.net/imxiangzi/article/details/7457703 在使用SecureCRT操作设备时,默认的回滚行数为500行.可以通过打开[选项]- ...
- SPI-软件开发注意事项
01 PD ,设置数据库前一定把模板设置号,命名规则规划清楚.
- C泊车管理系统
// // main.c // 泊车管理系统 // // Created by 丁小未 on 13-7-14. // Copyright (c) 2013年 dingxiaowei. All ...
- Android学习网站
1 <老罗Android应用开发视频教程> http://www.mobiletrain.org/about/news/android_video2.html
- Android仿360手机卫士悬浮窗效果
请看下图: 首先是一个小的悬浮窗显示的是当前使用了百分之多少的内存,点击一下小悬浮窗,就会弹出一个大的悬浮窗,可以一键加速.好,我们现在就来模拟实现一下 ...