
--------------STL------------
yphacker
心之所动,且就随缘去吧
展开
-
HDU1027 Ignatius and the Princess II
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027解题思路:求第m个全排列。直接用上STL里面的next_permutation库函数即可。AC代码:#include#include#includeusing namespace std;int main(){ int n,m; while原创 2014-12-05 23:55:16 · 415 阅读 · 0 评论 -
Codeforces 569B Inventory
题目链接:http://codeforces.com/contest/569/problem/B解题思路:Let's look at the problem from another side: how many numbers can we leave unchanged to get permutation? It is obvious: these numbers m原创 2015-08-11 09:18:29 · 553 阅读 · 0 评论 -
Codeforces 567C Geometric Progression
题目链接:http://codeforces.com/problemset/problem/567/C解题思路:Let's solve this problem for fixed middle element of progression. This means that if we fix element ai then the progression must c原创 2015-08-11 09:50:58 · 571 阅读 · 0 评论 -
Codeforces 567D One-Dimensional Battle Ships
题目链接:http://codeforces.com/problemset/problem/567/D解题思路:First, we should understand when the game ends. It will happen when on the n-sized board it will be impossible to place k ships of原创 2015-08-11 10:19:49 · 925 阅读 · 0 评论 -
POJ 2431 Expedition(优先队列)
题目链接:http://poj.org/problem?id=2431解题思路:我们稍微变换一下思考方式。在卡车开往终点的途中,只有在加油站才可以加油。但是,如果认为“在到达加油站i时,就获得了一次在之后的任意时候都可以加Bi单位汽油的权利”,在解决问题上应该也是一样的。而在之后需要加油时,就认为是在之前经过的加油站加的油就可以了。那么,因为希望到达终点时加油次数尽可能少,所以原创 2015-08-12 15:55:36 · 552 阅读 · 0 评论 -
hdu 5289 Assignment(RMQ,单调队列,multiset)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5289解题思路:解法1:枚举左端点,二分右端点,用st算法求区间最值解法2:用单调队列维护最值解法3:用multiset维护区间最值(这方法是队友在比赛中用的,我赛后重写了一遍。。。深刻体会了一下multiset的用法)AC代码:解法1:#include #in原创 2015-08-13 23:02:25 · 633 阅读 · 0 评论 -
STL之二:set/multiset用法详解
使用set或multiset之前,必须加入头文件Set、multiset都是集合类,差别在与set中不允许有重复元素,multiset中允许有重复元素。sets和multiset内部以平衡二叉树实现1. 常用函数1) 构造函数和析构函数set c:创建空集合,不包含任何元素set c(op):以op为排序准则,产生一个空的set原创 2015-08-05 17:30:22 · 711 阅读 · 0 评论 -
hdu 3627 Giant For(map+set模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3627解题思路:这题是hdu3626的加强版,如果直接暴力的话,肯定会超时,所以需要一点小小的优化,那就用map+set优化吧。。。AC代码:#include #include #include #include #include using namespace std原创 2015-09-11 17:05:17 · 585 阅读 · 0 评论 -
C++标准库:bitset 用法整理
std::bitset是STL的一部分,准确地说,std::bitset是一个模板类,它的模板参数不是类型,而整形的数值(这一特性是ISO C++2003的新特性),有了它我们可以像使用数组一样使用位。下面看一个例子:#includestd::bitset bs;//它是一个模板,传递的参数告诉编译器bs有8个位。我们接着看上面的代码,通过上面两行的代码我们得到一个bitset转载 2015-07-31 23:54:34 · 4981 阅读 · 0 评论 -
STL之一:map用法详解
#include #include #include #include using namespace std;int main(){ //声明(int为键,const char*为键) map m; //插入元素 m.insert(make_pair(1,"ONE")); m.insert(make_pair(10,"TEN"));原创 2015-08-12 08:52:00 · 380 阅读 · 0 评论 -
STL之一:vector用法详解
...原创 2015-08-05 00:08:57 · 793 阅读 · 0 评论 -
2010年山东省第一届ACM大学生程序设计竞赛——Ivan comes again!
题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2159Ivan comes again!题目大意:按照题目的操作做即可。。。简单的set应用。#include#include#include#include#includeusing namespace std原创 2015-05-04 22:23:45 · 517 阅读 · 0 评论 -
Codeforces 567B Berland National Library
题目链接:http://codeforces.com/contest/567/problem/B官方题解:To answer the queries correct, we need to know if the person is still in the library. For that purpose we will use in array of type b原创 2015-08-07 11:03:43 · 578 阅读 · 0 评论