HDU 1754线段树】的更多相关文章

I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 57279    Accepted Submission(s): 22365 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 线段树模板题,update功能是单点替换,query是访问区间最大值. #include <stdio.h> #include <algorithm> using namespace std; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 ; ]; void PushUP(int rt) { MAX[r…
线段树点修改  区间最大值查询 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <sstream> #include <string> #inclu…
I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 71311    Accepted Submission(s): 27589 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师…
---恢复内容开始--- 题意:给定区间,每个人的成绩, Q次询问,求每次询问区间中的最大值 思路:构造线段树 代码: #include<stdio.h> #include<algorithm> #include<string> #include<iostream> using namespace std; int n, m, ans; string str; struct Tree { int left, right, maxx; }tree[ * ];…
这个也是线段树的经验问题,待修改的,动态询问区间的最大值,只需要每次更新的时候,去把利用子节点的信息进行修改即可以. 注意更新的时候区间的选择,需要对区间进行二分. #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ; int b[maxx]; struct node{ int l; int r; int mid;…
Sample Input5 61 2 3 4 5Q 1 5 //1-5结点的最大值U 3 6 //将点3的数值换成6Q 3 4Q 4 5U 2 9Q 1 5 Sample Output5659 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # include <queue> # de…
代码线段树入门整理中有介绍. #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; <<; ; struct NODE{ int left,right; int value; }node[MAXNODE]; int father[MAX]; void buildtree(int i,int left,int right…
第一个自己动手写的线段树,1Y还是有点小激动哈(虽然是模版题) 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int SIZE=200005; 6 const int INF=1000000; 7 int maxv[SIZE<<2]; 8 int num[SIZE]; 9 void build(int l,int r,in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 #include <cstdio> #include <cmath> #include <algorithm> #include <iostream> #include <cstring> #include <queue> #include <vector> #define maxn 230050 #define lso…
第一次打 改了半天  各种小错误 难受 #include<cstdio> #include<iostream> using namespace std; +; int a[maxn],n; struct Node{ int l,r; long long Max,lazy; void update(long long val){ ;//本题没用 } }tree[maxn*]; void push_up(int x){ tree[x].Max=max(tree[x<<].M…
I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 52417    Accepted Submission(s): 20598 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感.不管你喜不喜欢,现在需要你做的是,就是按照老师的…
I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 31979    Accepted Submission(s): 12649 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要…
I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 59558    Accepted Submission(s): 23201 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要…
注意点:scanf中使用%c时,会读取空格和回车,所以在%c之前要有一个空格 ( 或者直接使用%s也行,%s会忽略空格和回车 ).具体见下面的代码: #include<iostream> #include<vector> #include<string> #include<cmath> #include<set> #include<algorithm> #include<cstdio> #include<map>…
#include<iostream> #include<cstring> using namespace std; ; int m,n,p; struct node{ int l,r; int v; }tr[N*]; void pushup(int u) { tr[u].v=max(tr[u<<].v,tr[u<<|].v); } void build(int u,int l,int r) { tr[u]={l,r}; if(l==r) { scanf(&q…
#include <algorithm> #include <iostream> #include<sstream> #include<cstring> #include<string> #include<cstdio> #include<cctype> #include<vector> #include<deque> #include<map> #include<set>…
Weak Pair Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 439    Accepted Submission(s): 155 Problem Description You are given a rooted tree of N nodes, labeled from 1 to N. To the ith node a…
Assign the task Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1647    Accepted Submission(s): 753 Problem Description There is a company that has N employees(numbered from 1 to N),every emplo…
Queue-jumpers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3348    Accepted Submission(s): 904 Problem Description Ponyo and Garfield are waiting outside the box-office for their favorite mo…
Sequence operation Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7502    Accepted Submission(s): 2233 Problem Description lxhgww got a sequence contains n characters which are all '0's or '1…
Transformation Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 65535/65536 K (Java/Others) Total Submission(s): 4095    Accepted Submission(s): 1008 Problem Description Yuanfang is puzzled with the question below:  There are n integers, a1,…
威威猫系列故事——晒被子 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 1592    Accepted Submission(s): 444 Problem Description 因为马拉松初赛中吃鸡腿的题目让不少人抱憾而归,威威猫一直觉得愧对大家,这几天他悄悄搬到直角坐标系里去住了. 生活还要继续,太阳也照常升起,今天,威威猫在…
Memory Control Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5913    Accepted Submission(s): 1380 Problem Description Memory units are numbered from 1 up to N. A sequence of memory units is c…
Adding New Machine Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1428    Accepted Submission(s): 298 Problem Description Incredible Crazily Progressing Company (ICPC) suffered a lot with the…
Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10208    Accepted Submission(s): 4351 Problem Description There are several ancient Greek texts that contain descriptions of the fabled i…
Picture Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3897    Accepted Submission(s): 1978 Problem Description A number of rectangular posters, photographs and other pictures of the same shape…
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4996    Accepted Submission(s): 1576 Problem Description Let A1, A2, ... , AN be N elements. You need to deal with…
Mex Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2482    Accepted Submission(s): 805 Problem Description Mex is a function on a set of integers, which is universally used for impartial game…
Level up Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3973    Accepted Submission(s): 1104 Problem Description Level up is the task of all online games. It's very boooooooooring. There is o…