随笔分类 -  STL

 
HDU 4557
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4557解决一类问题的set用法#include #include #include #include #include #include using namespace std ;char na[1005][20]... 阅读全文
posted @ 2014-08-18 10:12 LegendaryAC 阅读(230) 评论(0) 推荐(0)
HDU 4864
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4864#include #include #include #include #include #include #include using namespace std ;typedef __int64 ll ;... 阅读全文
posted @ 2014-08-18 09:48 LegendaryAC 阅读(183) 评论(0) 推荐(0)
HDU 4585
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4585从原来的人中找出战斗数值最接近的,输出他们两人的序号要在logn的复杂度完成查找,我用的是set,当然用map也可以,两个内部都是红黑树实现水题一道#include #include #include #in... 阅读全文
posted @ 2014-07-15 13:59 LegendaryAC 阅读(325) 评论(0) 推荐(0)
HDU 4268
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4268学会了multiset的用法,与set不同的是这个可以插入相同元素对w排序,对合适的w用multiset插入对应的h,logn完成查找#include #include #include #include #... 阅读全文
posted @ 2014-07-09 18:40 LegendaryAC 阅读(238) 评论(0) 推荐(0)
HDU 1702 ACboy needs your help again!
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1702G++交,基本stl栈和队列操作View Code #include <iostream>#include <stack>#include <queue>using namespace std ;int main(){ int t ; scanf("%d",&t) ; while(t--) { int n,m ; string str ; cin >> n >> str ; if(str=="FIFO&qu 阅读全文
posted @ 2012-07-27 14:05 LegendaryAC 阅读(261) 评论(0) 推荐(0)
HDU 2648 Shopping
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2648stl的map直接建立映射View Code #include <iostream>#include <algorithm>#include <string>#include <map>using namespace std ;string name[10001];int main(){ int n; while(~scanf("%d",&n)) { for(int i=0;i<n;i++) cin >> na 阅读全文
posted @ 2012-05-31 00:38 LegendaryAC 阅读(361) 评论(0) 推荐(0)
HDU 1708 Fibonacci String
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1708不能直接用string加,最后的位数很多,会超内存。一定注意特殊处理k=0和k=1的情况。最后有空行View Code #include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <stack>#include <queue>#include <map>#include <algorithm>using na 阅读全文
posted @ 2012-05-25 03:52 LegendaryAC 阅读(179) 评论(0) 推荐(0)
HDU 1022 Train Problem I
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1022STL中栈的应用练习,数组要开够啊。。。无语View Code #include <iostream>#include <stack>using namespace std;int main(){ stack <char> s; char in[11],out[11]; int n; bool flag[30]; while(~scanf("%d%s%s",&n,in,out)) { int i,j,cnt; i=j=cnt=0; ... 阅读全文
posted @ 2012-05-24 16:30 LegendaryAC 阅读(153) 评论(0) 推荐(0)
HDU 1280 前m大的数
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1280hash+最大堆,STL堆View Code #include <iostream>#include <map>#include <vector>#include <queue>#include <cstring>using namespace std;int hash[10001];int main(){ int n,m; priority_queue <int> q; while(~scanf("%d%d", 阅读全文
posted @ 2012-05-19 23:28 LegendaryAC 阅读(325) 评论(0) 推荐(0)
HDU 1029 Ignatius and the Princess IV
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1029看题意就是建立一个映射,用map直接过View Code #include <iostream>#include <map>using namespace std;int main(){ int n; while(~scanf("%d",&n)) { map <int ,int > M; int bz=(n+1)/2; while(n--) { int a; scanf("%d",&a)... 阅读全文
posted @ 2012-05-19 19:08 LegendaryAC 阅读(250) 评论(0) 推荐(0)
HDU 1678 Shopaholic
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1678继续是STL的堆,这道题最小堆最大堆均可,随手写一个就ok。刚开始题意理解有问题,各种wa,郁闷得要死。从最小堆来看,三个一组最小的加到答案里。如果元素总数不能被3整除,就先把堆顶元素出堆,直到能被3整除为止。View Code #include <iostream>#include <queue>#include <algorithm>using namespace std;int main(){ int t,n,p; int ans; priority_queue 阅读全文
posted @ 2012-05-11 12:06 LegendaryAC 阅读(237) 评论(0) 推荐(0)
HDU 4006 The kth great number
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4006第一反应是线段树,不过发现k是固定的。用STL的优先队列,很爽。http://blog.chinaunix.net/space.php?uid=533684&do=blog&cuid=2615612我从上面的博客学到很多STL优先队列的知识,ORZ一个View Code #include <iostream>#include <vector>#include <queue>using namespace std;int main(){ int n,k, 阅读全文
posted @ 2012-05-11 00:57 LegendaryAC 阅读(206) 评论(0) 推荐(0)
HDU 1027 Ignatius and the Princess II
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1027求数列n的第m个排列,STL中next_permutation的应用。相对应的还有prev_permutation。View Code #include #include #include #include using namespace std;int main(){ int n,m,i; int s[1100]; while(~scanf("%d%d",&n,&m)) { for(i=1;iusing namespace std ;int n,m ;int vi. 阅读全文
posted @ 2012-05-10 17:08 LegendaryAC 阅读(198) 评论(0) 推荐(0)
HDU 1263 水果
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1263STL中map的练习View Code #include <iostream>#include <map>#include <string>using namespace std;int main(){ int n,m,k,i; int f=0; scanf("%d",&n); while(n--) { if(!f)f++; else putchar('\n'); map <string ,map<string, 阅读全文
posted @ 2012-05-10 16:35 LegendaryAC 阅读(264) 评论(0) 推荐(0)
HDU 1075 What Are You Talking About
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1075趁着HDOJ活了赶快交一个、、、刚开始学习STL的应用,这个代码学习自sx老祖。。。View Code #include <stdio.h> #include <iostream> #include <string> #include <map>using namespace std; int main(){ int i; char str[3001]; map <string,string> M; string str1,str2; cin 阅读全文
posted @ 2012-05-10 12:46 LegendaryAC 阅读(235) 评论(0) 推荐(0)