ACM-ICPC 2018徐州网络赛-H题 Ryuji doesn't want to study
死于update的一个long long写成int了
真的不想写过程了 ********
树状数组,一个平的一个斜着的,怎么斜都行
题库链接:https://nanti.jisuanke.com/t/31460
#include <iostream>
#include <cstring> #define ll long long
#define lowbit(x) (x & -x) using namespace std; const int maxn = 1e5 + ;
int n, m;
ll t[maxn];
ll t1[maxn];
ll ans[maxn]; ll search(int pos, int r)
{
ll sum = ;
r = n - r;
while (pos)
{
sum += t[pos];
sum -= r * t1[pos];
pos -= lowbit(pos);
} return sum;
} void update(int pos, int val)
{
int x = pos;
while (pos <= n)
{
t[pos] += (n - x + ) * val;
t1[pos] += val;
pos += lowbit(pos);
}
} void update1(int pos, ll val)
{
val = val - search(pos, pos) + search(pos - ,pos);
int x = pos;
while (pos <= n)
{
t[pos] += (n - x + ) * val;
t1[pos] += val;
pos += lowbit(pos);
}
} void init()
{
memset(t, , sizeof(t));
memset(t1, , sizeof(t1)); for (int i = ; i <= n; i++)
update(i, ans[i]);
} int main()
{
ios::sync_with_stdio(false);
cin >> n >> m; for (int i = ; i <= n; i++)
cin >> ans[i]; init(); while (m--)
{
int op;
ll a, b;
cin >> op >> a >> b;
if (op == )
cout << search(b, b) - search(a - , b) << endl;
else
update1(a, b);
} return ;
}
ACM-ICPC 2018徐州网络赛-H题 Ryuji doesn't want to study的更多相关文章
- ACM-ICPC 2018青岛网络赛-H题 Traveling on the Axis
题目:略(不知道怎么从ZOJ搬题) 地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4054 把这题的每个点分成两种情况 ...
- 2018徐州网络赛H. Ryuji doesn't want to study
题目链接: https://nanti.jisuanke.com/t/31458 题解: 建立两个树状数组,第一个是,a[1]*n+a[2]*(n-1)....+a[n]*1;第二个是正常的a[1], ...
- hdu 4438 第37届ACM/ICPC 天津赛区现场赛H题
题意:Alice和Bob两个人去打猎,有两种(只)猎物老虎和狼: 杀死老虎得分x,狼得分y: 如果两个人都选择同样的猎物,则Alice得分的概率是p,则Bob得分的概率是(1-p): 但是Alice事 ...
- 2019 ICPC南京站网络赛 H题 Holy Grail(BF算法最短路)
计蒜客题目链接:https://nanti.jisuanke.com/t/41305 给定的起点是S,终点是T,反向跑一下就可以了,注意判负环以及每次查询需要添加边 AC代码: #include< ...
- ICPC 2019 徐州网络赛
ICPC 2019 徐州网络赛 比赛时间:2019.9.7 比赛链接:The Preliminary Contest for ICPC Asia Xuzhou 2019 赛后的经验总结 // 比赛完才 ...
- ACM ICPC 2018 青岛赛区 部分金牌题题解(K,L,I,G)
目录: K Airdrop I Soldier Game L Sub-cycle Graph G Repair the Artwork ———————————————————— ps:楼主脑残有点严 ...
- 2018 ACM南京网络赛H题Set解题报告
题目描述 给定\(n\)个数$a_i$,起初第\(i\)个数在第\(i\)个集合.有三种操作(共\(m\)次): 1 $u$ $v$ 将第$u$个数和第$v$个数所在集合合并 2 $u$ 将第$u$个 ...
- The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 K题 center
You are given a point set with nn points on the 2D-plane, your task is to find the smallest number o ...
- hdu 4431 第37届ACM/ICPC 天津赛区现场赛A题 枚举
题意:就是给了13张牌.问增加哪些牌可以胡牌.m是数字,s是条,p是筒,c是数字 胡牌有以下几种情况: 1.一个对子 + 4组 3个相同的牌或者顺子. 只有m.s.p是可以构成顺子的.东西南北这样 ...
随机推荐
- Kafka Zookeeper 基本命令示例
Kafka 新建Topic bin/kafka-topics. --replication-factor --partitions --topic my-topic 查看已存在Topic列表 bin/ ...
- linux系统如何更改文件权限
一. 更改文件9个属性:chmod 用这个命令修改文件属性有两种方式:数字或者符号 1. 数字类型改变文件权限 chmod (1)类unix系统的文件有9个属性分别是owner/group/other ...
- 测试URL
http://localhost:8080/dmonitor-webapi/monitor/vm/342?r=1410331220921&indexes=cpu&indexes=mem ...
- vue与django中预防CSRF
一.环境: vue2.0.django 1.10.x.iview 二.django后台处理 1.将django的setting的MIDDLEWARE中加入django.middleware.csrf. ...
- vmware centos7 静态ip设置
最近在学习linux环境部署~~~~ 首先,将网络适配设置成为桥接模式 查看本机IP地址,ipconfig,记住ipv4地址和默认网关地址,等会配置的时候要用 启动Centos,进入终端模式,设置IP ...
- 数字图像处理:基于MATLAB的车牌识别项目 标签: 图像处理matlab算法 2017-06-24 09:17 98人阅读 评论(0)
学过了数字图像处理,就进行一个综合性强的小项目来巩固一下知识吧.前阵子编写调试了一套基于MATLAB的车牌识别的项目的代码.今天又重新改进了一下代码,识别的效果好一点了,也精简了一些代码.这里没有使用 ...
- Windows Server 2012 R2 Standard x64 deploy Visual Studio 2015 Application
When I run the Server application on Windows Server 2012 R2 operation system. I meet the error:MSVCP ...
- 高性能python编程之协程(stackless)-乾颐堂
我们都知道并发(不是并行)编程目前有四种方式,多进程,多线程,异步,和协程. 多进程编程在python中有类似C的os.fork,当然还有更高层封装的multiprocessing标准库,在之前写过的 ...
- [GO]使用bufio的文件读取方式
package main import ( "os" "fmt" "bufio" "io" ) func ReadFil ...
- java grpc实例分析
一.Protocol Buffer 我们还是先给出一个在实际开发中经常会遇到的系统场景.比如:我们的客户端程序是使用Java开发的,可能运行自不同的平台,如:Linux.Windows或者是Andro ...