![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL&数据结构
文章平均质量分 61
西风丶
这个作者很懒,什么都没留下…
展开
-
hdu 5676 ztr loves lucky numbers(STL大法好)
原贴地址 #include #include #include using namespace std; char b[50],c[50]; int main() { int t; scanf("%d", &t); while (t--) { scanf("%s", b);转载 2016-05-02 21:10:10 · 322 阅读 · 0 评论 -
HDU5651(逆元)
点击打开链接 (a/b)%c=a*b^(c-2)%c c为质数 #include #include #include #define N 1000000007 using namespace std; typedef long long ll; ll quickpow(ll a,ll b) { ll r=1,c=a; while(b)原创 2016-05-09 21:18:15 · 267 阅读 · 0 评论 -
HDU5510 Bazinga 暴力strstr+剪枝
点击打开链接 题意:给定n个字符串,求出满足条件:存在j 直接暴力超时,需要剪枝。 如果判断出串A是串B的字串,下次就可以不用判断A了。因为如果串B是串C的字串,那么串A一定也是串C的字串。 #include #include #include using namespace std; char a[503][2003]; int visit[503]; int m原创 2016-07-12 15:56:14 · 319 阅读 · 0 评论 -
HDU5875 - 大连网赛1008(单调栈)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5875 思路:显然F(l , r) = Al % A(l+1) % ***Ar,大于当前数的直接跳过。 #include #include #include using namespace std; const int N = 1e5 + 10; int a[N] ,Next[N]; stack s原创 2016-09-11 20:25:59 · 291 阅读 · 0 评论 -
HDU 5876 (大连网赛1009)(BFS + set)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意:给定一个图(n个顶点m条边),求其补图最短路 思路:集合a表示当前还未寻找到的点,集合b表示本次bfs之后仍未寻找到的点 #include #include #include #include using namespace std; const int N = 2e5 + 5; s原创 2016-09-14 15:31:59 · 237 阅读 · 0 评论 -
codeforces 707D-(DFS+bitset)
题目链接:http://codeforces.com/contest/707/problem/D 根据询问建立一棵树然后DFS。 #include using namespace std; const int N=1e3+3; const int maxn=1e5+3; int n,m,q; vector G[maxn]; bitset bit[N]; bitset opp; int ope[原创 2016-08-24 21:49:43 · 382 阅读 · 0 评论 -
codeforces 675D Tree Construction (map)
题目链接:http://codeforces.com/contest/675/problem/D 题意:建立一棵二叉搜索树,比当前节点小的放左边,否则放右边。问编号2~n的节点的父节点数值是多少。 思路:如果用普通的建树方法来做,在遇到深度较深的树时会超时。map的lower_bound(t)返回第一个key大于等于t的位置it,所以t必定在(it.second,it.firs原创 2016-09-04 19:11:02 · 287 阅读 · 0 评论 -
codeforces 651C(map、去重)
题目链接:http://codeforces.com/contest/651/problem/C 思路:结果就是计算同一横坐标、纵坐标上有多少点,再减去可能重复的数量(用map,pair存一下就OK了)。 #include using namespace std; typedef long long ll; typedef pair pii; const int N = 2e5 + 5; m原创 2016-10-05 21:03:32 · 494 阅读 · 0 评论