上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 24 下一页
摘要: http://poj.org/problem?id=2823 【题意】 给定一个长度为n的序列,求长度为k的滑窗内的最大值和最小值 【思路】 裸的单调队列 注意用C++提交,不然会T,orz我用G++T了好长时间 【AC】 1 //#include<bits/stdc++.h> 2 #include 阅读全文
posted @ 2017-08-28 14:33 shulin15 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 【题意】 给定一个n*m的矩阵,求所有大小为k*k的正方形中(最大值-最小值)的最小值 【思路】 先横着算出每一行的长度为k的窗口内的最大值,变成一个n*(m-k+1)的矩阵mx 再竖着算出每一列的长度为k的窗口内的最大值,变成一个(n-k+1)*(m-k+1)的矩阵t1(在mx的基础上算) 问题到 阅读全文
posted @ 2017-08-28 14:03 shulin15 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 【题意】 维护一个单调递减的q数组,用id数组记录q数组的每个下标对应在原数组的位置,那么id数组一定有单调性(q数组中越靠后,原数组中也靠后),然后二分查找这个数 【AC】 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef lon 阅读全文
posted @ 2017-08-28 12:46 shulin15 阅读(188) 评论(0) 推荐(0) 编辑
摘要: poj.org/problem?id=1236 【题意】 给定一个有向图,求: (1)至少要选几个顶点,才能做到从这些顶点出发,可以到达全部顶点 (2)至少要加多少条边,才能使得从任何一个顶点出发,都能到达全部顶点 【思路】 (1)强连通分量缩点后形成一个有向无环图,只要选择入度为0的顶点,其他顶点 阅读全文
posted @ 2017-08-27 22:16 shulin15 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 【AC】 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 int n; 5 const int maxn=1e3+2; 6 const int maxm=1e6+2; 7 const int inf 阅读全文
posted @ 2017-08-27 17:59 shulin15 阅读(143) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4031 【题意】 有一个长为n的长城,进行q次操作,d为防护罩的冷却时间,Attack表示区间a-b的墙将在1秒后受到攻击, 询问表示计算第a块墙受到攻击的次数,被防护罩抵消的不算 【思路】 总的攻击次数-防护罩抵 阅读全文
posted @ 2017-08-26 22:15 shulin15 阅读(200) 评论(0) 推荐(0) 编辑
摘要: http://codevs.cn/problem/1082/ 【AC】 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn=2e5+2; 5 int n; 6 ll a[m 阅读全文
posted @ 2017-08-26 21:12 shulin15 阅读(331) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4267 【思路】 树状数组的区间修改:在区间[a, b]内更新+x就在a的位置+x. 然后在b+1的位置-x 树状数组的单点查询:求某点a的值就是求数组中1~a的和. (i-a)%k==0把区间分隔开了,不能直接套 阅读全文
posted @ 2017-08-26 17:29 shulin15 阅读(153) 评论(0) 推荐(0) 编辑
摘要: http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1335 【题意】 给定n座桥的高度,给定m次洪水每次的涨水水位ai和退水水位bi 询问有多少座桥被淹的次数大于等于k 洪水最开始的水位为1 【思路】 每座桥被淹一次是这样的:开始时的水位小于桥的高 阅读全文
posted @ 2017-08-26 15:24 shulin15 阅读(161) 评论(0) 推荐(0) 编辑
摘要: acm.hdu.edu.cn/showproblem.php?pid=4135 【题意】 询问[a,b]中与n互质的数有多少个 【思路】 考虑[1,m]中与n互质的数有多少个,答案就是query(b)-query(a-1) 正难则反,考虑[1,m]中与n不互质的数有多少个 求出n的所有素因子a1,a 阅读全文
posted @ 2017-08-25 20:52 shulin15 阅读(120) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 24 下一页