- 博客(41)
- 资源 (7)
- 收藏
- 关注
原创 HDU 3468 Treasure Hunting(二分匹配+最短路)
Problem DescriptionDo you like treasure hunting? Today, with one of his friend, iSea is on a venture trip again. As most movie said, they find so many gold hiding in their trip.Now iSea’s clever
2016-07-31 18:18:06 1260
原创 HDU 5773 The All-purpose Zero (DP最长上升子序列)
Problem Description?? gets an sequence S with n intergers(0 < n <= 100000,0<= S[i] <= 1000000).?? has a magic so that he can change 0 to any interger(He does not need to change all 0 to the same i
2016-07-28 17:21:55 833
原创 算法总结:【线段树+扫描线】&矩形覆盖求面积/周长问题(HDU 1542/HDU 1828)
问题:给出若干个矩形,(给的是矩形左上角和右下角坐标),求最后所得图形的面积/周长;三个矩形如左图所示,而若要计算面积,看右图,用3个矩形各自的面积之和减去重复部分(红色和蓝色)的面积人算很简单,但是用算法怎么实现呢?此类问题一般都是用线段树辅助扫描法来计算;什么是扫描法?有什么用?怎么用?可以想象成一根假想的线,将图从左往右或从右往左或自下而上或自上而下“扫描”一遍,至于
2016-07-27 20:52:08 16288 11
原创 HDU 5296 Annoying problem(LCA模板+树的dfs序心得)
Problem DescriptionCoco has a tree, whose nodes are conveniently labeled by 1,2,…,n, which has n-1 edge,each edge has a weight. An existing set S is initially empty.Now there are two kinds of op
2016-07-25 00:33:16 1724
原创 HDU 5294 Tricks Device(最短路+最大流)
Problem DescriptionInnocent Wu follows Dumb Zhang into a ancient tomb. Innocent Wu’s at the entrance of the tomb while Dumb Zhang’s at the end of it. The tomb is made up of many chambers, the tota
2016-07-24 16:18:14 1159
原创 HDU 5323 Solve this interesting problem(dfs结合线段树特点剪枝)
Problem DescriptionHave you learned something about segment tree? If not, don’t worry, I will explain it for you.Segment Tree is a kind of binary tree, it can be defined as this:- For each nod
2016-07-23 21:04:16 565
原创 HDU 5316 Magician(线段树区间合并)
Problem DescriptionFantasy magicians usually gain their ability through one of three usual methods: possessing it as an innate talent, gaining it through study and practice, or receiving it from a
2016-07-23 20:39:27 715
原创 HDU 1394 Minimum Inversion Number(用规律取代线段树)
Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj.For a given sequence of numbers a1, a2, ..., an, if we mov
2016-07-21 21:23:40 323
原创 STL之resize()函数
size() 目前容器正拥有的元素个数capacity() 容器能储存的元素个数,即容量reserve() 重新指定容器能存储数据的个数resize() 重新指定容器有效的元素个数设元素原本的v.size()是n 当调用v.resize(m)后,有两种情况:1.若 m 2.若m > n ,则容器之前储存的n个元素不变,不足m的部分补0#includeu
2016-07-20 17:24:09 4398
转载 浅谈LCA的离线算法
在线算法与离线算法的定义在计算机科学中,一个在线算法是指它可以以序列化的方式一个个的处理输入,也就是说在开始时并不需要已经知道所有的输入。相对的,对于一个离线算法,在开始时就需要知道问题的所有输入数据,而且在解决一个问题后就要立即输出结果。例如,选择排序在排序前就需要知道所有待排序元素,然而插入排序就不必。因为在线算法并不知道整个的输入,所以它被迫做出的选择最后可能会被证明
2016-07-20 14:55:04 673
原创 POJ 3264 Balanced Lineup(水题试ST算法模板)
题目链接:点击打开链接查询区间最值问题,如果询问次数非常多,ST算法比线段树快(毕竟是O(1)查询)但是现实是线段树用的比ST多(毕竟功能强大,也不会很慢) LCA问题提供了ST(在线)和Tarjan(离线)两种算法(。。。)试水题。。。。。。。。。。。。。试ST算法模板。。。。。。。。。。。。。。。#include#include#include#include
2016-07-20 10:38:42 471
原创 POJ 2415 Hike on a Graph(bfs)
Description"Hike on a Graph" is a game that is played on a board on which an undirected graph is drawn. The graph is complete and has all loops, i.e. for any two locations there is exactly one arr
2016-07-19 23:52:57 479
原创 HDU 1532 Drainage Ditches(增广路dfs&bfs模板)
Problem DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long t
2016-07-19 00:42:00 578
原创 HDU 5301 Buildings(思维:一道简单的难题)
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must determine a way to split the floor building with walls to make apartments in the shape of a rectang
2016-07-18 21:39:01 468
原创 HDU 5305 Friends(dfs)
Problem DescriptionThere are n people and m pairs of friends. For every pair of friends, they can choose to become online friends (communicating using online applications) or offline friends (
2016-07-18 21:06:55 467
原创 二分查找和lower_bound & upper_bound
问题:对于事先排好序的非递减数列,查找其中值为val的下标,如果val不存在则返回-1二分查找,数学中有利用二分法求近似值的方法也是这个原理数列是非递减的,只需步步尝试逼近所需要的值#includeusing namespace std;int BinarySearch(const int A[],int val,int N){ int left,right,
2016-07-17 20:59:01 1628
原创 最大子序列和问题四种解(O)
方法一: 最简单粗暴的想法,以每个点i为起点,以i后面的每个点为终点,求和取最小 for (i = 0 -> n) for (j = i -> n) for (k = i->j) 三重循环,时间复杂度O(N^3)#includeusing namespace std;int MaxSubsequenceSum(const int A[],in
2016-07-17 20:09:32 880 3
原创 HDU 3912 Turn Right(模拟)
Problem DescriptionThis summer, ELT and his classmates went to Beijing for a training of coding. ELT have never been to Beijing before, so at the weekend, he together with some friends went to the
2016-07-17 03:33:20 607
原创 HDU 1226 超级密码(BFS)
Problem DescriptionIgnatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息:密码是一个C进制的数,并且只能由给定的M个数字构成,同时密码是一个给定十进制整数N(0注意:由于宝藏的历史久远,当时的系统最多只能保存500位密码.因此如果得到的密码长度大于500也不能用来开启房门
2016-07-16 19:14:37 626
原创 关于大数取模
常常遇到的mod再大也只是1e9+7之类int范围内的数然后在a*b%mod的时候只需要把a,b开成long long就避免了溢出问题但是如果mod 是一个很大很大的数呢?(这样即使a,b全是long long型,在相乘的时候依旧会溢出之前看大素数测定的时候看到一个方法:a*b%c:typedef long long ll;ll mult_mod (ll a,ll b,
2016-07-16 16:33:19 2209
原创 HDU 4771 Stealing Harry Potter's Precious(bfs+状态压缩)
Problem Description Harry Potter has some precious. For example, his invisible robe, his wand and his owl. When Hogwarts school is in holiday, Harry Potter has to go back to uncle Vernon's home.
2016-07-15 18:34:47 415
原创 POJ 1129 Channel Allocation(dfs模拟图的上色问题)
DescriptionWhen a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a strong signal. However, the channels used by each r
2016-07-14 22:47:57 631
原创 STL之unique()去重函数
CF上的代码是开放的,常常就能看到本渣与大神们的差距比如去重。。。这是本鶸代码。。。。。。。#include#include#includeusing namespace std;const int N = 100000;int a[N+5];int b[N+5];int main(){ int n; while (cin>>n) {
2016-07-14 12:04:48 30635 7
原创 HDU 3974 Assign the task(并查集)
Problem DescriptionThere is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediat
2016-07-14 03:34:27 767
原创 HDU 4339 Query(线段树)
Problem DescriptionYou are given two strings s1[0..l1], s2[0..l2] and Q - number of queries.Your task is to answer next queries: 1) 1 a i c - you should set i-th character in a-th string to c
2016-07-14 01:08:34 492
原创 HDU 3008 Warcraft(DP之状态的保存)
Problem DescriptionHave you ever played the Warcraft?It doesn't matter whether you have played it !We will give you such an experience.There are so many Heroes in it,but you could only choose one
2016-07-13 19:53:50 579
原创 HDU 4536 XCOM Enemy Unknown(DFS暴力水过)
Problem DescriptionXCOM-Enemy Unknown是一款很好玩很经典的策略游戏.在游戏中,由于未知的敌人--外星人入侵,你团结了世界各大国家进行抵抗.随着游戏进展,会有很多的外星人进攻事件.每次进攻外星人会选择3个国家攻击,作为联盟的指挥者,你要安排有限的联盟军去支援其中一个国家,抵抗进攻这个国家的外星人.战斗胜利之后这个被支
2016-07-12 16:48:25 960
原创 HDU 3209 Scales(模拟三进制运算)
Problem DescriptionGive you a scale, a goods weigts m kilograms. And then give you some stones weighting 1, 3, 9, 27, ..., 3^k. Of course, the number of different weights' is only ONE.Now put
2016-07-11 00:26:19 796 2
原创 POJ 2923Relocation(状态压缩入门)
DescriptionEmma and Eric are moving to their new house they bought after returning from their honeymoon. Fortunately, they have a few friends helping them relocate. To move the furniture, they onl
2016-07-10 00:53:25 1525
原创 UVA 11825 Hackers' Crackdown(状态压缩DP)
题目链接:code://Must so#include#include#include#include#define mem(a,x) memset(a,x,sizeof(a))#define inf (1<<29)using namespace std;typedef long long ll;/* 读题就读了半天=-= N台电脑,每台有N种服务
2016-07-09 21:46:15 400
原创 数论快速入门(同余、扩展欧几里德、中国剩余定理、大素数测定和整数分解、素数三种筛法、欧拉函数以及各种模板)
数学渣渣愉快的玩了一把数论,来总结一下几种常用的算法入门,不过鶸也是刚刚入门, 所以也只是粗略的记录下原理,贴下模板,以及入门题目(感受下模板怎么用的)一、同余定理简单粗暴的说就是:若 a-b == m 那么 a%m == b%m这个模运算性质一眼看出。。。直接上入门水题:Reduced ID Numbers附AC代码(这个也没啥模板。。。。知道就好)#includ
2016-07-09 13:25:11 3662 4
原创 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. The city counci
2016-07-08 10:03:07 988 1
原创 POJ 1324Holedox Moving (状态BFS)
Holedox MovingTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 15264 Accepted: 3686DescriptionDuring winter, the most hungry and severe time, Holedox sle
2016-07-07 00:18:57 1193
原创 HDU 2333Assemble(简单二分)
AssembleTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 628 Accepted Submission(s): 230Problem DescriptionRecently your team
2016-07-06 03:22:02 1255 2
原创 HDU 4608 I-number(暴力模拟)
I-numberTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3968 Accepted Submission(s): 1415Problem DescriptionThe I-number of
2016-07-06 02:53:08 603
原创 HDU 1043 Eight(经典八数码问题)对比POJ 1077(bfs)
题目链接:点击打开链接事情是这样的,我先在TLE无数发之后A了POJ的1077,然后在VJ上看到“原题”,然而,此原题被我TLE5发MLE9发,最后从学长那里学得记录路径的方法之后才过,却原来,这道所谓原题并非原题!!!HDU 的1043和POJ的1077都叫Eight,但是由于HDU上是多组数据POJ上单组,所以POJ上直接正常bfs搜索, HDU上则需要预处理。。。方法是一样的
2016-07-06 01:30:18 837
原创 HDU 1025 最长上升子序列(nlogn)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1025第一次写最长上升子序列不是写的这题,所以对于这个最长上升子序列的模板题也没什么好说的,主要坑点在于,如果答案是一road用单数..............[cpp] view plain copy//Must so
2016-07-06 01:05:31 512
原创 HDU 1058Humble Numbers(dp)
题目被分类为dp,那么这样的解法应该也是dp吧题目:http://acm.hdu.edu.cn/showproblem.php?pid=1058注意一下输出格式就好[cpp] view plain copy//Must so #include #define mem(a,x) memset(a,x,si
2016-07-06 01:02:50 276
原创 Codeforces Round #143 (Div. 2) C (解题报告)
DescriptionA piece of paper contains an array of n integers a1, a2, ..., an. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for
2016-07-06 01:00:14 578
原创 HDU 1072 Nightmare (时间重置)BFS
Problem DescriptionIgnatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb
2016-07-06 00:58:06 953
学生社团管理系统--Java界面版
2017-03-03
游戏坦克大战(Java实现)
2016-09-04
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人