3211: 花神游历各国
来源:互联网 发布:淘宝信用卡作用 编辑:程序博客网 时间:2024/06/10 09:03
3211: 花神游历各国
Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 2438 Solved: 908
[Submit][Status][Discuss]
Description
Input
Output
每次x=1时,每行一个整数,表示这次旅行的开心度
Sample Input
4
1 100 5 5
5
1 1 2
2 1 2
1 1 2
2 2 3
1 1 4
1 100 5 5
5
1 1 2
2 1 2
1 1 2
2 2 3
1 1 4
Sample Output
101
11
11
11
11
HINT
对于100%的数据, n ≤ 100000,m≤200000 ,data[i]非负且小于10^9
Source
SPOJ2713 gss4 数据已加强
#include<iostream>#include<cstdio>#include<queue>#include<vector>#include<bitset>#include<algorithm>#include<cstring>#include<map>#include<stack>#include<set>#include<cmath>#include<ext/pb_ds/priority_queue.hpp>using namespace std;const int maxn = 1E5 + 10;const int T = 6;typedef long long LL;int n,m;bool Mark[maxn*T];LL c[maxn*T];void Insert(int o,int l,int r,int pos,int x){if (l == r) {c[o] = x;if (c[o] <= 1) Mark[o] = 1;return;}int mid = (l + r) >> 1;if (pos <= mid) Insert(o<<1,l,mid,pos,x);else Insert(o<<1|1,mid+1,r,pos,x);c[o] = c[o<<1] + c[o<<1|1];if (Mark[o<<1] && Mark[o<<1|1]) Mark[o] = 1;}LL Query(int o,int l,int r,int ql,int qr){if (ql <= l && r <= qr) return c[o];int mid = (l + r) >> 1;LL ret = 0;if (ql <= mid) ret += Query(o<<1,l,mid,ql,qr);if (qr > mid) ret += Query(o<<1|1,mid+1,r,ql,qr);return ret;}void Modify(int o,int l,int r,int ml,int mr){if (Mark[o]) return;if (l == r) {c[o] = floor(sqrt(c[o]));if (c[o] <= 1) Mark[o] = 1;return;}int mid = (l + r) >> 1;if (ml <= mid) Modify(o<<1,l,mid,ml,mr);if (mr > mid) Modify(o<<1|1,mid+1,r,ml,mr);c[o] = c[o<<1] + c[o<<1|1];if (Mark[o<<1] && Mark[o<<1|1]) Mark[o] = 1;}int getint(){int ch = getchar();int ret = 0;while (ch < '0' || '9' < ch) ch = getchar();while ('0' <= ch && ch <= '9')ret = ret*10 + ch - '0',ch = getchar();return ret;}int main(){#ifdef DMCfreopen("DMC.txt","r",stdin);#endifn = getint();for (int i = 1; i <= n; i++) {int x = getint();Insert(1,1,n,i,x);}m = getint();while (m--) {int typ,l,r;typ = getint();l = getint();r = getint();if (typ == 1) printf("%lld\n",Query(1,1,n,l,r));else Modify(1,1,n,l,r);}return 0;}
0 0
- 3211: 花神游历各国
- 3211: 花神游历各国
- bzoj-3211 花神游历各国
- [BZOJ 3211] 花神游历各国
- bzoj 3211 花神游历各国
- BZOJ 3211 花神游历各国
- BZOJ 3211 花神游历各国
- [bzoj-3211]花神游历各国 题解
- 【bzoj3211】花神游历各国
- 【BZOJ3211】花神游历各国
- 【bzoj3211】花神游历各国
- BZOJ3211花神游历各国
- [BZOJ3211]花神游历各国
- bzoj3211 花神游历各国
- [bzoj3211]花神游历各国
- bzoj3211花神游历各国
- bzoj3211 花神游历各国
- bzoj3211花神游历各国
- AsyncTask使用
- 06 intent flag三种属性
- POI操作Excel详解,HSSF和XSSF两种方式
- 优化算法综述
- Spring Test 整合 JUnit 4 使用
- 3211: 花神游历各国
- M101P: MongoDB for Developers - Chapter 4: Performance
- XML解析
- 应用架构B/S与C/S优劣比较(二)
- mysql-proxy解决只能内网访问线上数据库问题
- 继承_方法的重写
- Jenkins Plugin 基础开发入门
- Caffe ImageNet例程翻译
- 01背包问题