BZOJ2223 [Coci 2009]PATULJCI】的更多相关文章

题目描述 输入  先输入一个数n,然后一个数表示这n个数中最大的是多少,接下来一行n个数.然后一个数m,最后m行询问每次两个数l,r. 输出 no或者yes+这个数 样例输入 10 3 1 2 1 2 1 2 3 2 3 3 8 1 2 1 3 1 4 1 5 2 5 2 6 6 9 7 10 样例输出 noyes 1noyes 1noyes 2noyes 3 提示 Notice:输入第二个整数是序列中权值的范围Lim,即1<=ai(1<=i<=n)<=Lim. 1<=Lim…
传送门 主席树经典题目. 直接利用主席树差分的思想判断区间中数的个数是否合法然后决定左走右走就行了. 实际上跟bzoj3524是同一道题. 代码: #include<bits/stdc++.h> #define N 300005 using namespace std; int n,m,sig,rt[N],ql,qr; struct Tree{ int son[N*30][2],siz[N*30],tot; inline void update(int&p,int las,int l,…
求区间内个数大于rank的一个数 主席树求一下就好啦! /************************************************************** Problem: 2223 User: rausen Language: C++ Result: Accepted Time:704 ms Memory:54712 kb ****************************************************************/ #inclu…
不带修改主席树裸题<=>莫队+权值分块裸题. 复杂度O(m*sqrt(n)). P.S.题目描述坑爹,第二个数是权值的范围. #include<cstdio> #include<algorithm> #include<cmath> using namespace std; #define N 300001 #define M 10001 int f,c; inline void R(int &x){ c=0;f=1; for(;c<'0'||c…
[Coci 2009]PATULJCI Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 1286  Solved: 553[Submit][Status][Discuss] Description Input   Output 10 31 2 1 2 1 2 3 2 3 381 21 31 41 52 52 66 97 10 Sample Input noyes 1noyes 1noyes 2noyes 3 Sample Output   HINT…
题目大意 给定一个大小为n,每个数的大小均在[1,c]之间的数列,你需要回答m个询问,其中第i个询问形如\((l_i, r_i)\),你需要回答是否存在一个数使得它在区间\([l_i,r_i]\)中出现至少\(\frac{r-l+1}{2}\)次. 题解 第一次写主席树. 不难发现,对于一个询问,只有可能要么有解,要么有一个解. 考虑到每个数均在一个确定的区间内,我们考虑开一棵权值线段树(以前一直用这种方法,但不知到这就是权值线段树)来记录每一个数字的出现次数. 考虑到他要求询问一个区间,我们只…
Description Input   Output 10 3 1 2 1 2 1 2 3 2 3 3 8 1 2 1 3 1 4 1 5 2 5 2 6 6 9 7 10 Sample Input no yes 1 no yes 1 no yes 2 no yes 3 Sample Output   HINT Notice:输入第二个整数是序列中权值的范围Lim,即1<=ai(1<=i<=n)<=Lim. 依旧主席树模板,无需离散化. 1<=Lim<=10000 So…
题目描述 样例输入 10 3 1 2 1 2 1 2 3 2 3 3 8 1 2 1 3 1 4 1 5 2 5 2 6 6 9 7 10 样例输出 no yes 1 no yes 1 no yes 2 no yes 3 题目大意 第一行输入n和lim,为序列数的个数和数的范围(1≤a[i]≤lim) 第二行输入n个数. 第三行输入m,为询问个数. 以下m行输入询问,如题. 对于每个询问,如果存在,输出yes和这个数,否则输出no. 题解 bzoj格式错了... 主席树. 对于每个询问,判断它能…
题目链接1 题目链接2 主席树模板题 两题有细节不同 #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<cmath> #include<ctime> #include<queue> #include<stack…
题目:[POI2014]KUR-Couriers 题解: 要求出现次数大于(R-L+1)/2的数,这样的数最多只有一个.我们对序列做主席树,每个节点记录出现的次数和(sum).(这里忽略版本差值问题)对于一个节点,如果左儿子的sum小于等于(R-L+1)/2,则答案不可能在左儿子中:右儿子同理.然后对有可能的儿子递归寻找答案,如果左右儿子都不可能,则不存在答案. 代码: BZOJ 3524: #include<cstdio> #include<cstring> #include&l…