- 博客(13)
- 收藏
- 关注
原创 树状数组_Rotate HDU2688
Problem DescriptionRecently yifenfei face such a problem that give you millions of positive integers,tell how many pairs i and j that satisfy F[i] smaller than F[j] strictly when i is smaller than j
2017-05-19 11:51:34 245
原创 树状数组_Ping pong
AC代码#include #include using namespace std;#define lowbit(x) (x&-x)#define maxn 1000000typedef long long ll;ll n,a[maxn],c[maxn],d[maxn],s1[maxn],s2[maxn],x[maxn];ll sum(ll x){ ll r
2017-05-16 18:20:19 184
原创 反转法_Face The Right Way(POJ.3276)
题目链接:http://poj.org/problem?id=3276题意:每次反转k头牛,使得所有牛都为F,输出反转次数m最小时的k和m(一定有解)思路:同一个区间反转 两次及以上是多余的,区间反转的顺序对结果没影响#include #include #include using namespace std;#define INF 0x3f3f3f3fint dir[5
2017-05-11 15:52:42 325
原创 解题报告_HDU.1004Let the Balloon Rise_map
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004难度:简单题意:找出出现次数最多的颜色并输出思路:用map容器的键存颜色,用值存次数,然后遍历map找次数最多的元素#include #include #include #include using namespace std;int main(){ int
2017-05-09 17:56:07 215
原创 解题报告_HDU1412{A} + {B}_set
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1412难度:简单思路:将集合A,B的元素都添加到集合C中,再遍历输出集合C#include #include #include using namespace std;int main(){ int n,m; while(scanf("%d%d",&n,&m)!
2017-05-09 17:51:36 221
原创 解题报告_HDU.2094产生冠军_set
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2094难度:set模板题思路:在out集合里的一定不是冠军,然后all集合减去out集合为可能为冠军的,若可能为冠军的人数为1,则可确定冠军#include #include #include #include using namespace std;int main(){
2017-05-09 17:41:00 244
原创 学习总结_STL_map
头文件:声明:(第一个为键,第二个为值)map m; //声明一个map容器mmap::iterator ite; //声明一个指向map容器内元素的指针map m; //此时string为键,int为值map m; //node为结构体,struct node{int id;string name;};插入元素:m.insert(m
2017-05-09 16:00:28 217
原创 最小生成树_Conscription(POJ.3723)
题目链接:http://poj.org/problem?id=3723#topAC代码#include #include #include using namespace std;struct edge{ int u,v,cost;};edge es[50050];int x,y,z;int par[20020];bool comp(const edg
2017-05-08 17:59:17 199
原创 图论_最短路问题
Dijkstra(迪杰斯特拉)算法适用范围:没有负边核心思想:(1)找到最短距离已经确定的顶点中最短距离最小的顶点u,从它出发更新所有相邻顶点的距离(2)然后就不需要关心u并重复(1)时间复杂度:O(|E|log|V|)/*题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 */#include #inclu
2017-05-07 17:22:02 176
原创 题解_Automatic Judge
题目链接:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1001&cid=772时间超限的代码:超限原因:sort函数占时过多#include #include #include using namespace std;int n,m;typedef struct{ int num;
2017-05-07 14:16:14 288
原创 学习总结_STL_string
头文件:<string> 声明:string x; x为变量名 函数:getline(cin,x); 默认以换行符为终点getline(cin,x,'#'); 以#为终点 头文件:<sstream> 声明:istringstream x; x为变量名,初始化操作为istringstream x("1 ...
2017-05-07 10:17:45 202
原创 学习总结_STL_set
头文件:特性:不允许重复元素声明:元素类型为int型:set x; //x为变量名元素类型为char型:set x; //要加一个头文件函数:insert() 往容器内添加元素,O(logn),x.insert(find() 判断容器内是否有某元素,没有的话返回end(),if(x.find(n)==x.end())
2017-05-07 09:06:51 162
原创 学习总结_STL_优先队列
头文件: 声明:数据大的优先级高:priority_queue que; //数据类型为int型,que为变量名数据小的优先级高:priority_queue, greater > que; //数据类型为int型数据类型为结构体:priority_queue que;#include #include #include using namesp
2017-05-05 10:21:44 229
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人