
ACM_数据结构
文章平均质量分 83
张思瑶126
If you think you can , you can !
不怕千万人阻挡,只怕自己投降 !
展开
-
逆序数 & 逆序对
文章作者:Yx.Ac 文章来源:勇幸|Thinking (http://www.ahathinking.com) 转载请注明,谢谢合作。---设A[1…n]是一个包含n个不同数的数组。如果在iA[j],则(i,j)就称为A中的一个逆序对(inversion)【《算法导论》2-4】现给出一个数列,求该数列中的逆序对数(逆序数)。本节给出三种方法:方法一是最直接的暴力方转载 2015-08-10 14:48:32 · 846 阅读 · 0 评论 -
NBUT 1218 You are my brother
[1218] You are my brother时间限制: 1000 ms 内存限制: 131072 K问题描述Little A gets to know a new friend, Little B, recently. One day, they realize that they are family 500 years ago. Now, Little A w原创 2015-08-18 15:47:16 · 1018 阅读 · 0 评论 -
HDU 3342 Legal or Not
Legal or NotTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6069 Accepted Submission(s): 2818Problem DescriptionACM-DIY is a原创 2015-08-17 10:24:28 · 717 阅读 · 0 评论 -
HDU 1166 敌兵布阵(线段树)
这是第二次写这道题的题解了,上次是用树状数组写的。http://blog.youkuaiyun.com/zhang_xueping/article/details/47123951虽然在去年暑假的时候曾经试过学习线段树,但是后来由于觉得麻烦所以放弃了,碰巧遇到这道题,就百度找题解,发现树状数组的代码简单多了,就认真看了几遍,大概把模板记住了,然后自己敲出来了。当时特开心,天真的以为线段树的原创 2015-08-15 10:48:47 · 602 阅读 · 0 评论 -
HDU 2795 Billboard (线段树)
BillboardTime Limit: 20000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15625 Accepted Submission(s): 6580Problem DescriptionAt the entranc原创 2015-08-15 11:35:08 · 637 阅读 · 0 评论 -
HDU 3460 Ancient Printer (字典树)
Ancient PrinterThe contest is beginning! While preparing the contest, iSea wanted to print the teams' names separately on a single paper. Unfortunately, what iSea could find was only an ancient printer: so ancient that you can't believe it, it only had原创 2015-08-15 17:28:33 · 812 阅读 · 0 评论 -
HDU 1754 I Hate It(线段树维护 区间最值)
I Hate ItTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 51228 Accepted Submission(s): 20100Problem Description很多学校流行一种比较的习惯。原创 2015-08-15 11:16:07 · 422 阅读 · 0 评论 -
HDU 1856 More is better
DescriptionMr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be. Of course there are certain requirements. Mr Wa原创 2014-09-10 21:32:19 · 437 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers (线段树,成段更新,区间求和)
Description给出了一个序列,你需要处理如下两种询问。"C a b c"表示给[a, b]区间中的值全部增加c (-10000 ≤ c ≤ 10000)。"Q a b" 询问[a, b]区间中所有值的和。Input第一行包含两个整数N, Q。1 ≤ N,Q ≤ 100000.第二行包含n个整数,表示初始的序列A (-1000000000 ≤原创 2015-08-10 18:23:32 · 556 阅读 · 0 评论 -
NBUT 1220 SPY
[1220] SPY时间限制: 1000 ms 内存限制: 131072 K问题描述The National Intelligence Council of X Nation receives a piece of credible information that Nation Y will send spies to steal Nation X’sconf原创 2015-08-18 20:12:39 · 1047 阅读 · 0 评论 -
线段树 & 区间更新 & 延时标记
一 概述线段树,类似区间树,是一个完全二叉树,它在各个节点保存一条线段(数组中的一段子数组),主要用于高效解决连续区间的动态查询问题,由于二叉结构的特性,它基本能保持每个操作的复杂度为O(logn)。线段树的每个节点表示一个区间,子节点则分别表示父节点的左右半区间,例如父亲的区间是[a,b],那么(c=(a+b)/2)左儿子的区间是[a,c],右儿子的区间是[c+1,b]。转载 2015-08-12 23:05:08 · 489 阅读 · 0 评论 -
【STL】vector 用法总结
一、Vector 的部分用法:#include #include using namespace std;int main(){ vector a; a.push_back(1); a.push_back(2); a.push_back(3); a.push_back(4); a.push_back(5); for(int i =原创 2015-08-25 20:59:05 · 607 阅读 · 0 评论 -
C++ 【STL】 map的基本操作和使用
原文网址:http://blog.sina.com.cn/s/blog_61533c9b0100fa7w.html Map是c++的一个标准容器,它提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1. map最基本的构造函数; mapmapstring; mapmapin转载 2015-08-25 21:40:34 · 480 阅读 · 0 评论 -
HDU 1698 Just a Hook
Just a HookTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 23147 Accepted Submission(s): 11604Problem DescriptionIn the game原创 2015-08-26 15:23:24 · 578 阅读 · 0 评论 -
string和stringstream用法总结
原文网址:http://blog.youkuaiyun.com/xw20084898/article/details/21939811一、stringstring 是 C++ 提供的字串型態,和 C 的字串相比,除了有不限长度的优点外,还有其他许多方便的功能。要使用 string, 必須先加入这一行:#include 接下來要宣告一个字串变量,可以写成:stri转载 2015-08-21 23:24:11 · 3418 阅读 · 0 评论 -
C++中 pair 的用法
#include#include#include#include#include#include#include#include#includeusing namespace std;map m;pair p;int main() { p = make_pair("one",1);//make_pair(),返回一个pair类型 cout << p.原创 2015-08-24 17:40:27 · 1390 阅读 · 0 评论 -
线段覆盖长度
文章作者:Yx.Ac 文章来源:勇幸|Thinking (http://www.ahathinking.com) 转载请注明,谢谢合作。---给定一些线段,线段有起点和终点,求这些线段的覆盖长度,重复的部分只计算一次。这是在小桥流水博客中看到的一道面试题(小米科技),后来为了练习线段树这个数据结构,就做了一下这道题,本节给出两种方法,一种是基于排序来做的,一种是使用转载 2015-08-10 15:07:03 · 877 阅读 · 1 评论 -
UVA 12657 Boxes in a Line
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4395题目意思是说,给出一个数n,表示存在一个整数序列1……n,然后进行四种操作:操作一:输入x,y,表示将x移到y的左边(若x本来就在y的左边则忽略);操作二:输入x,y,表原创 2015-08-17 21:50:40 · 1000 阅读 · 0 评论