![](https://img-blog.csdnimg.cn/20190918135101160.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
ACM-数据结构
文章平均质量分 86
数据结构和高级数据结构算法题
_txg
平凡,是为了最美的荡气回肠
展开
-
hdu_4284 (Floyd求最短路+dfs遍历)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4284TravelTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4458 Accepted Submissi原创 2017-07-26 21:17:24 · 334 阅读 · 0 评论 -
hdu-4821(BKDRHash字符串哈希)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4821 String Given a string S and two integers L and M, we consider a substr原创 2017-07-26 11:19:35 · 519 阅读 · 0 评论 -
I - A计划 (BFS)
可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。 现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用P表示,时空传输机用#表示,墙用*表原创 2017-05-17 17:08:50 · 321 阅读 · 0 评论 -
(one data one problem)hdu-5792 World is Exploding (树状数组)
题目链接:点击打开链接Problem DescriptionGiven a sequence A with length n,count how many quadruple (a,b,c,d) satisfies: a≠b≠c≠d,1≤ab≤n,1≤cd≤n,AaAb,Ac>Ad. InputThe input consists of multip原创 2017-04-24 11:06:27 · 342 阅读 · 0 评论 -
(one day one problem) codeforces 468/problem/B Two Sets (并查集)
题目链接:http://codeforces.com/contest/468/problem/BLittle X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must b原创 2017-04-19 14:34:43 · 425 阅读 · 0 评论 -
2017省组队练习 Number of Connected Components UVALive - 7638 (数论+并查集)
题目链接:点击打开链接Given N nodes, each node is labeled with an integer between 1 and 106(inclusive and labels arenot necessarily distinct). Two nodes have an edge between them, if and only if the GCD (Great原创 2017-04-19 13:58:05 · 565 阅读 · 0 评论 -
2017省组队训练 zoj 3385Hanami Party (贪心+栈优化)
题目链接:点击打开链接Saigyouji Yuyuko and Konpaku Youmu are going to hold a hanami party (a Japanese traditional custom of enjoying the beauty of cherry blossoms). They decide to invite all their friends原创 2017-04-19 12:27:44 · 425 阅读 · 0 评论 -
2017省选拔(三)Poj1182 食物链 (并查集)
直接点击打开链接动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用原创 2017-04-19 11:18:20 · 251 阅读 · 0 评论 -
2017省选拔(二)poj3494 Largest Submatrix of All 1’s (单调栈+预处理)
直击链接:点击打开链接Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements.InputThe input contains mu原创 2017-04-19 10:51:39 · 440 阅读 · 0 评论 -
2017sdut省赛选拔(1)--poj2559(单调栈的应用)
http://poj.org/problem?id=2559Largest Rectangle in a HistogramTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 21489Accepted: 6923DescriptionA h原创 2017-04-11 11:45:06 · 491 阅读 · 0 评论 -
2017sdut省赛选拔(1)--poj2155(二维线段树的翻转)
http://poj.org/problem?id=2155MatrixTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 27032 Accepted: 9906DescriptionGiven an N*N matrix A, whose原创 2017-04-11 11:23:50 · 263 阅读 · 0 评论 -
玲珑杯-1112 (倍增+二分)
DESCRIPTION小 L 有一串 QQ 个数排成一排,从左往右是 A1A1 开始一直到 AQAQ,它一直很喜欢这串数。有一天,小 L 去高考报名了,小 J 和小 N 过来用这串数玩游戏。一开始,小 N 手上有一个空序列,定义变量C:=0C:=0。小 J 从左往右依次把序列中的数取出,放到小 N 手上序列的最右边,如果放完之后,整个序列的混乱度超过了原创 2017-04-11 10:54:39 · 415 阅读 · 0 评论 -
2016山东省第七届ACM省赛-部分题解
sdut-3560-julyed:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3560.htmlJulyedProblem Description Julyed is preparing for her CET-6. She has N words to rememb原创 2017-04-11 10:35:15 · 2410 阅读 · 0 评论 -
Contest - 2017年浙江理工大学程序设计竞赛校赛
点击:http://oj.acm.zstu.edu.cn/JudgeOnline/contest.php?cid=3650Problem A: 回文Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1637 Solved: 505Description小王想知道一个字符串是否为ABA’型字符串。ABA’型字符原创 2017-03-22 15:30:09 · 2226 阅读 · 0 评论 -
The Tower of Babylon UVA - 437 (DAG上的动态规划变形,记忆化搜索)
Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of this talehave been forgotten. So now, in line with the educational nature of this contest, we will tell you thewh原创 2017-03-10 21:43:08 · 381 阅读 · 0 评论 -
A - Fill UVA - 10603 (寻找路径,搜索优化)
There are three jugs with a volume of a, b and c liters. (a, b, and c are positive integers not greaterthan 200). The first and the second jug are initially empty, while the third is completely filled原创 2017-03-01 22:01:23 · 375 阅读 · 0 评论 -
cf 777B _ B. Game of Credit Cards (排序比较)
http://codeforces.com/contest/777/problem/BAfter the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competition原创 2017-02-24 20:03:26 · 1009 阅读 · 0 评论 -
Problem on Group Trip UVALive - 7219 (模拟+优先队列处理)
点击打开链接题目大意:有三个浴池s1,s2,s3,有n个人。每个人在每个浴池中所呆的时间为s[i].m1,s[i].m2,s[i].m3. 每次进浴池的时候要按n个人的序号的大小进行排队。310 25 150 0 250 15 10例如上面这组数据,有三个人,第一个人在s1中的时间是10,在s2中的时间是25,在s3中的时间是15,0表示这个人不需要再该浴池中,而且原创 2017-02-18 16:09:34 · 522 阅读 · 0 评论 -
Coconuts HDU - 5925 (离散化+dfs求联通块)
http://acm.hdu.edu.cn/showproblem.php?pid=5925TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams about eating. One day, TanBig dreams of a field of coconuts, and the f原创 2017-02-16 18:08:33 · 435 阅读 · 0 评论 -
poj 1699—Best Sequence(dfs剪枝)
http://poj.org/problem?id=1699DescriptionThe twenty-first century is a biology-technology developing century. One of the most attractive and challenging tasks is on the gene project, especiall原创 2017-02-10 20:15:20 · 864 阅读 · 0 评论 -
poj 3280 Cheapest Palindrome(区间dp)
点击:http://poj.org/problem?id=3280DescriptionKeeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an electronic原创 2017-01-16 11:08:24 · 322 阅读 · 0 评论 -
poj 2352 Stars
题目链接:http://poj.org/problem?id=2352DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a s原创 2016-12-06 22:02:44 · 1706 阅读 · 0 评论 -
poj 3114 Countries in War(强连通分支缩点+最短路)
题目链接:http://poj.org/problem?id=3114DescriptionIn the year 2050, after different attempts of the UN to maintain peace in the world, the third world war broke out. The importance of industrial原创 2016-12-05 20:29:40 · 386 阅读 · 0 评论 -
poj 3592 Instantaneous Transference (借助强连通分量求缩点在建图spfa求最长路)
题目链接:http://poj.org/problem?id=3592DescriptionIt was long ago when we played the game Red Alert. There is a magic function for the game objects which is called instantaneous transfer. When an原创 2016-11-30 20:20:17 · 422 阅读 · 0 评论 -
poj 2186 Popular Cows (有向图的联通分量问题)
DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that t原创 2016-11-28 21:26:02 · 470 阅读 · 0 评论 -
vj Om Nom and Dark Park
DescriptionOm Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scar原创 2016-11-01 21:36:50 · 522 阅读 · 0 评论 -
poj 3368 Frequent values
题目链接:点击打开链接DescriptionYou are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j原创 2016-10-31 21:58:06 · 269 阅读 · 0 评论 -
主席树解析
转载:http://www.cnblogs.com/zyf0163/p/4749042.html自己的话:现在感觉对主席树模模糊糊的,有点抽象到底是怎么回事,但还是有所收获主席树又称函数式线段树,顾名思义,也就是通过函数来实现的线段树,至于为什么叫主席树,那是因为是fotile主席创建出来的这个数据结构(其实貌似是当初主席不会划分树而自己想出来的另一个处理方式。。。。是不是很吊呢?转载 2016-10-20 21:08:31 · 525 阅读 · 0 评论 -
poj 1195 Mobile phones
题目链接:点击打开链接DescriptionSuppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * S matrix w原创 2016-10-18 19:54:58 · 391 阅读 · 0 评论 -
poj 3122 Apple Tree
题目链接:点击打开链接#include #include#include#includeusing namespace std;///直接开vectormp[100005]会tle don't know why?typedef vectorve;vectormp(100005);int forck[100005];int c[100005];int n;int ke原创 2016-10-17 20:53:51 · 279 阅读 · 0 评论 -
树状数组详解
对于普通数组,其修改的时间复杂度位O(1),而求数组中某一段的数值和的时间复杂度为O(n),因此对于n的值过大的情况,普通数组的时间复杂度我们是接受不了的。在此,我们引入了树状数组的数据结构,它能在O(logn)内对数组的值进行修改和查询某一段数值的和。转载地址:http://blog.csdn.net/ljd4305/article/details/10101535树状数组是一个查询转载 2016-10-17 19:53:56 · 371 阅读 · 0 评论 -
线段树求逆序数(模板)
经过两天的调试终于弄明白了线段树求逆序数,;说一下思路: 首先建树是根据序列中最大的数开辟的区间,(如果数太大 离散化)。 逆序对可以表示成一个数前面有几个比这个数大的数,就表示这个数所形成的逆序对数,(听绕口的,需要模拟一下); 数列a[i],将数列a[i]添加到线段树中,并将区间中有它的区间的num+1,意思是在当前的区间上有几个值了,记录下来。 因为原创 2016-10-11 11:31:37 · 1004 阅读 · 0 评论 -
poj 2528 Mayor's posters(线段树+离散化)
题目链接:点击打开链接DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim.原创 2016-09-26 21:49:26 · 273 阅读 · 0 评论 -
poj 3122 Pie
题目链接:点击打开链接DescriptionMy birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are c原创 2016-09-18 20:32:43 · 324 阅读 · 0 评论 -
codeforce C. Learning Languages(并查集)
题目链接:点击打开链接The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers原创 2016-09-07 21:23:53 · 547 阅读 · 0 评论 -
codeforce New Problem(dfs)
题目链接:点击打开链接Coming up with a new problem isn't as easy as many people think. Sometimes it is hard enough to name it. We'll consider a title original if it doesn't occur as a substring in any原创 2016-09-07 15:07:57 · 319 阅读 · 0 评论 -
poj 1905 Expanding Rods
题目链接:点击打开链接DescriptionWhen a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is mounted on tw原创 2016-08-24 15:27:49 · 355 阅读 · 0 评论 -
poj 3274 Gold Balanced Lineup
题目链接: 点击打开链接DescriptionFarmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K di转载 2016-08-23 19:10:40 · 301 阅读 · 0 评论 -
poj 3246 Balanced Lineup (RMQ)
题目链接:点击打开链接DescriptionFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with som原创 2016-08-19 09:01:26 · 546 阅读 · 0 评论 -
poj 3468 A Simple Problem with Integers
题目链接:点击打开链接DescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interv原创 2016-08-18 21:10:27 · 225 阅读 · 0 评论