HDU-6703 array】的更多相关文章

题目大意:给出一个n个元素的数组A,A中所有元素都是不重复的[1,n].有两种操作:1.将pos位置的元素+1e72.查询不属于[1,r]中的最小的>=k的值.强制在线. 题解因为数组中的值唯一,且在1到n的范围内,而询问的r和k也在1到n的范围内. 所以对于任意一个被操 作1修改过的值都不会成为询问的答案,而询问的结果也必然在k到n+1的范围内. 因为没有被修改过 值是唯一的,所以可以建立权值线段树,维护权值区间内的值所在下标的最大值.而询问则转化为不小 于k的值里面,下标超过r的最小权值是多…
Problem Description You are given an array a1,a2,...,an(∀i∈[1,n],1≤ai≤n). Initially, each element of the array is **unique**.Moreover, there are m instructions.Each instruction is in one of the following two formats:1. (1,pos),indicating to change th…
Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5587 Description Vicky is a magician who loves math. She has great power in copying and creating.One day she gets an array {1}. After that, every day she cop…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6197 题意:给你n个数,问让你从中删掉k个数后(k<=n),是否能使剩下的序列为非递减或者非递增序列 解法:签到题,就是让你求最长不下降子序列长度len,然后判断下n-len是否小于k(将序列反着存下来然后再求即最长不上升子序列,取两者len中的较大值),然后直接套nlogn的模板即可. #include <bits/stdc++.h> using namespace std; const…
题目链接:hdu 5587 前两周 bc 上的题了,因为赶大作业所以没有去打,看了下官方给出的思路,感觉好强大~~竟然能转化成求二进制数 1 的个数: 然后数位 dp 就行了, #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef unsigned long long ull; #define For(i,s,t) for(int i = s; i <…
array array array Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 459    Accepted Submission(s): 282 Problem Description One day, Kaitou Kiddo had stolen a priceless diamond ring. But detective…
Array Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Vicky is a magician who loves math. She has great power in copying and creating.One day she gets an array {1}. After that, every day she c…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6172 题意:如题. 解法: #include <bits/stdc++.h> using namespace std; typedef long long LL; const LL mod = 1e9+7; struct Matrix{ LL a[3][3]; void set1(){ memset(a, 0, sizeof(a)); } void set2(){ memset(a, 0, siz…
Array Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 417    Accepted Submission(s): 211 Problem Description Vicky is a magician who loves math. She has great power in copying and creating.One…
正反跑一次LIS,取最大的长度,如果长度大于n-k就满足条件. ac代码: #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <map> #include <stack> #include <algorithm> using namespace std; int dp]; int LIS(int a[],in…
题意:对于一个序列,要求去掉正好K个数字,若能使其成为不上升子序列或不下降子序列,则“A is a magic array.”,否则"A is not a magic array.\n". 分析: 1.求一遍LCS,然后在将序列逆转,求一遍LCS,分别可得最长上升子序列和最长下降子序列的长度tmp1.tmp2. 2.n - tmp1 <= k或n - tmp2 <= k即可,需要去掉的去完之后,在已经是最长上升或最长下降的序列中随便去够k个就好了. #include<…
题意:给出,三个函数,h,b,a,然后T次询问,每次给出n,求sqrt(an); 思路:不会推,但是感觉a应该是线性的,这个时候我们就可以用BM线性递推,自己求出前几项,然后放到模板里,就可以求了. 数据范围在1e15,1000组都可以秒过. ( 那么主要的问题就是得确保是线性的,而且得求出前几项. 如果是K<1e6次多项式,我们可以用拉格朗日插值法求第N项,比如求K次方的前缀和,先放着,有空以启整理了. #include<bits/stdc++.h> using namespace s…
HDU 6703 array   题意:   给定一个数组 \(a_1,a_2, a_3,...a_n\) ,满足 \(1 \le a[i]\le n\) 且 \(a[i]\) 互不相同.   有两种操作:1. 将 \(a_{pos}\) 的值加上 100000000:2. 询问不等于任何 \(a[i], (1 \le i \le r)\) 且不小于 \(k\) 的最小值.   思路:   注意 \(n,k\) 的范围都不超过 100000,对于操作一,相当于删除了这个数(询问的答案一定在区间…
多校10 1002 HDU 6172 Array Challenge 题意 There's an array that is generated by following rule. \(h_0=2,h_1=3,h_2=6,h_n=4h_{n-1}+17h_{n-2}-12h_{n-3}-16\) And let us define two arrays bnandan as below. $ b_n=3h_{n+1} h_n+9h_{n+1} h_{n-1}+9h_n^2+27h_n h_{n…
^&^ (HDU 6702) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem DescriptionBit operation is a common computing method in computer science ,Now we have two positive integers A and B ,Please find a positive in…
HDU 6197 array array array 题意 输入n和k,表示输入n个整数和可以擦除的次数k,如果至多擦除k次能是的数组中的序列是不上升或者是不下降序列,就是魔力数组,否则不是. 解题思路 分别求最长不下降和不上升子序列的长度,看不符合要求的数字和k的大小. 这里使用优化后的求解最长不上升和不下降子序列的算法. #include <cstdio> #include <algorithm> using namespace std; ; ; int A[maxn], B[…
目录 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 6702 & 6703 array 6704 K-th occurrence 6705 path 6706 huntian oy 6707 Shuffle Card 6708 Windows Of CCPC 6709 Fishing Master @ 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 CSDN 6702 & \(1 and 1\)的话,\(c\)就必须为\(1\).其他的贪心选\(0\). 注意c为…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5280 Senior's Array Description One day, Xuejiejie gets an array $A$. Among all non-empty intervals of $A$, she wants to find the most beautiful one. She defines the beauty as the sum of the interval. Th…
这是BC上的一道题,当时比赛没有做,回头看看题解,说是AC自动机,想着没有写过AC自动机,于是便试着抄抄白书的模板,硬是搞了我数个小时2000ms时限1800过了= = ! 这里就直接贴上BC的结题报告(#27):http://bestcoder.hdu.edu.cn/solutions.php 1003 Matching on Array 首先我们考虑m=1的情况.给定两个数组A={a1,a2,…,an}和B={b1,b2,…,bk},问B在A中出现了几次.令ci=ai+1ai,1≤i<n,同…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5635 LCP Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 282    Accepted Submission(s): 79 Problem Description Peter has a string s=s1s2..…
Bomber Man wants to bomb an Array. 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5653 Description Given an array and some positions where to plant the bombs, You have to print the Total Maximum Impact. Each Bomb has some left destruction capability…
hdu 6197 题意:给定一个数组,问删掉k个字符后数组是否能不减或者不增,满足要求则是magic array,否则不是. 题解:队友想的思路,感觉非常棒!既然删掉k个后不增或者不减,那么就先求数组的最长不下降子序列的长度l1和最长不上升子序列的长度l2,若l1>=n-k||l2>=n-k,则满足要求. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm&g…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5653 题意:已知炸弹可以炸掉左边L个位置,右边R个位置,那么炸点炸掉的总数是L+R+1.给定每个炸弹的位置,求所有炸弹炸掉的格数总乘积 输出floor(1e6*log2(总乘积))那么到计算时就变成先取对数相加,最后乘以1e6下取整 思路:dp[r]=dp[l-1]*log2(r-l+1)当前区间的最大值等于上一个区间的最大值加上当前的值,解释见代码 #include<cstdio> #inclu…
GCD Array Time Limit: 11000/5500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 843    Accepted Submission(s): 205 Problem Description Teacher Mai finds that many problems about arithmetic function can be reduced to…
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 447    Accepted Submission(s): 201 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort,…
http://acm.hdu.edu.cn/showproblem.php?pid=5532  题目大意: 给你一个不规则的序列,问是否能够通过删除一个元素使其成为一个有序的序列(递增或递减(其中相邻的元素可以相等))   将序列里分成两种可能讨论,该序列除了一个元素之外要么递增要么递减,只需满足一个即可   #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #i…
Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted array. We say an array…
Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has an array A of length n,and the ith element of A is equal to the sum of all digits of i…
http://acm.hdu.edu.cn/showproblem.php?pid=5532 题意大致是一组数中去掉一个数后问剩下的数是否构成非严格单调序列 正反各跑一遍最长非严格连续子序列,存在长度大于等于n-1的就满足YES,注意这里的YES NO都是大写 #include<cstdio> using namespace std; ],c[]; int main() { int t,i,j,n; scanf("%d",&t); while (t--) { sca…
题目链接 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted array. We say an a…