自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 收藏
  • 关注

原创 nyoj - 168房间安排

房间安排时间限制:3000 ms  |  内存限制:65535 KB难度:2描述2010年上海世界博览会(Expo2010),是第41届世界博览会。于2010年5月1日至10月31日期间,在中国上海市举行。本次世博会也是由中国举办的首届世界博览会。上海世博会以“城市,让生活更美好”(Better City,Better Life)为主题,将充分探索21世纪城市生活。这次世博会总投资达450亿人民币...

2018-04-29 16:53:42 185

原创 Currency Exchange - Bellman

Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can...

2018-04-29 14:43:40 152

原创 Silver Cow Party - 最短路(逆矩阵)

One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M≤ 100,000) unidirectional (one-way roa...

2018-04-28 21:58:59 504

原创 Dijkstra的变形 - Heavy Transportation、Frogger

变形一:求每条路径中边的最大值,然后求所有路径的边的最小值的最大值。变形二:求每条路径中边的最大值,然后求所有路径的边的最大值的最小值。理解题意是关键啊……注意:cost数组的初始值不一样啊啊啊,求边最小值的最大值,设初始值为0求边最大值的最小值,设初始值为1。变形一的题:Heavy TransportationBackground Hugo Heavy is happy. After the b...

2018-04-27 21:50:17 174

原创 最短路问题 - dijkstra算法、Bellman_Ford算法、SPFA模板、Floyd算法

寻找最短路径指的是找出从图中某个结点出发到达另一个结点所经过的边的权重之和最小的那条路径。这里的最短路不仅仅指一般意义上的距离最短,还可以引申到时间,费用等最小。算法中的最短路问题类型:1:单源最短路:给定一个源结点,求出这个点到其他所有点的最短路径,有Dijkstra和Bellman-ford两种算法,Dijkstra只能求解所有边权都为正的情况,Bellman-ford可以求解边权为正或...

2018-04-26 21:41:06 781

原创 2.3合并排序的递归、非递归算法,自然合并排序

递归算法将待排元素分成大小大致相同的两个子集合,分别对这两个集合进行排序,最终将排好序的子集合合并。#include<iostream> #include<cstdio> void Merge(int s[],int t[],int b,int m,int e){//将s[b...m]与s[m+1...e]合并 int i=b;//i->前一...

2018-04-26 11:33:22 6768 1

原创 2.2分治思想 - 二分搜索、大整数乘法、棋盘覆盖、Strassen矩阵乘法

分治的基本思想:当要求解一个输入规模n相当大的问题时,直接求解往往是非常困难的,甚至没法求出。正确的方法是, 首先应仔细分析问题本身所具有的特性,然后根据这些特性选择适当的设计策略来求解。在将这n个输入分成k个不同子集合的情况下,如果能得到k个不同的可独立求解的子问题,而且在求解之后,还可找到适当的方法把它们合并成整个问题的解,那么,可考虑使用分治法来求解。分治法所能解决的问题一般具有以下几个特征...

2018-04-25 20:00:19 673

原创 A Simple Problem with Integers - 线段树(改变区间的值)

You 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 interval. The other is to ask for the ...

2018-04-23 08:52:05 173

原创 Just a Hook - 线段树(改变区间的值)

 In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now ...

2018-04-20 12:19:45 133

原创 I Hate It - 线段树(改变点的值)

很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000 ),分...

2018-04-20 11:54:16 117

原创 敌兵布阵 - 线段树讲解(改变点的值)

C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所以...

2018-04-19 20:55:48 248

原创 Zjnu Stadium - 带权并查集

In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of people. The audience Seats made a circl...

2018-04-19 19:51:17 192

原创 How Many Answers Are Wrong - 带权并查集(详解)

TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should w...

2018-04-19 19:42:02 728

原创 Rochambeau

N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest children are divided into three groups (it is possible that some group is empty). You don’t kn...

2018-04-14 17:49:10 400

原创 食物链 - 并查集的两种解法(详解)

动物王国中有三类动物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个动物,用上述两种说法,一句接一句地说出K句话...

2018-04-12 21:51:59 6992 10

原创 Find them, Catch them - 并查集

The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which g...

2018-04-11 21:56:22 1278 1

原创 第六章 - uva679 - Dropping Balls (详解)

if the flag’s current value at this node is false, then the ball will first switch this flag’s value, i.e., fromthe false to the true, and then follow the left subtree of this node to keep moving down...

2018-04-08 21:14:53 270

原创 第六章 - Rails - uva514 - stack、模拟

There is a famous railway station in PopPush City. Country there is incredibly hilly. The stationwas built in last century. Unfortunately, funds were extremely limited that time. It was possible toest...

2018-04-07 21:23:53 176

原创 第六章 - Matrix Chain Multiplication - uva442 - stack

Suppose you have to evaluate an expression like A*B*C*D*E where A,B,C,D and E are matrices.Since matrix multiplication is associative, the order in which multiplications are performed is arbitrary.How...

2018-04-07 21:03:09 285

原创 Dragon Balls

Five hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Monkey King(WuKong) to gather all of the dragon balls together. His country has N cities and ...

2018-04-07 13:45:30 464

原创 Wannafly挑战赛13 - B Jxc的军训

链接:https://www.nowcoder.com/acm/contest/80/B来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld题目描述 在文某路学车中学高一新生军训中,Jxc正站在太阳下站着军姿,对于这样的酷热的阳光,Jxc 表示非常不爽。 Jxc将天空看做一个n...

2018-04-07 10:26:16 454

原创 Cube Stacking

Farmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with N stacks, each containing a single cube. Farmer John asks Betsy to perform ...

2018-04-06 21:43:58 131

原创 Wireless Network

An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...

2018-04-06 19:32:14 309

转载 超有爱的并查集~

转载自:点击打开链接例子就是杭电上的畅通工程:http://acm.hdu.edu.cn/showproblem.php?pid=1232首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整幅图一共有几个连通分支,也就是被分成了几个互相独立的块。像畅通工程这题,问还需要修...

2018-04-06 11:31:36 164

原创 第四章 - uva201 - Squares

A children’s board game consists of a square array of dots that contains lines connecting some of thepairs of adjacent dots. One part of the game requires that the players count the number of squares ...

2018-04-06 10:34:57 302

原创 2018年东北农业大学春季校赛 L - wyh的天鹅

链接:https://www.nowcoder.com/acm/contest/93/L来源:牛客网时间限制:C/C++ 3秒,其他语言6秒空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld题目描述 你们wyh学长小时候住在河边,因为周围的生态环境非常好,所以经常会有天鹅浮在湖面上,每只天鹅都长得不一样,它们偶尔排成一排,偶尔分散开,偶尔也会...

2018-04-05 19:52:05 265 2

原创 n的阶乘末尾有几个0

链接:https://www.nowcoder.com/acm/contest/93/E来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld题目描述 这个问题很简单,就是问你n的阶乘末尾有几个0? 输入描述:输入第一行一个整数T(1<=T<=100),代表测试组数接下来T行,每行...

2018-04-05 18:57:07 995

原创 2018年东北农业大学春季校赛 D - why的迷宫

链接:https://www.nowcoder.com/acm/contest/93/D来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld题目描述 给你一个n*m的迷宫,这个迷宫中有以下几个标识: s代表起点 t代表终点 x代表障碍物 .代表空地 现在...

2018-04-05 18:38:28 367

原创 2018年东北农业大学春季校赛 B - wyh的矩阵,F - wyh的集合

链接:https://www.nowcoder.com/acm/contest/93/B来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld题目描述 给你一个n*n矩阵,按照顺序填入1到n*n的数,例如n=5,该矩阵如下 1 2 ...

2018-04-05 18:28:15 238 1

原创 牛客练习赛14 A-n的约数(详解)

链接:https://www.nowcoder.com/acm/contest/82/A来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld题目描述 t次询问,每次给你一个数n,求在[1,n]内约数个数最多的数的约数个数 输入描述:第一行一个正整数t之后t行,每行一个正整数n输出描述:输出t...

2018-04-04 11:35:15 261

原创 第四章 - Message Decoding - uva213

Some message encoding schemes require that an encoded message be sent in two parts. The first part,called the header, contains the characters of the message. The second part contains a pattern thatrep...

2018-04-01 16:39:41 183

原创 第四章 - The Dole Queue - uva 133

In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour RhinocerosParty has decided on the following strategy. Every day all dole applicants will be placed in a largeci...

2018-04-01 11:39:04 173

原创 第四章 - Hangman Judge - uav489

In “Hangman Judge,” you are to write a program that judges a series of Hangman games. For eachgame, the answer to the puzzle is given as well as the guesses. Rules are the same as the classic gameof h...

2018-04-01 10:07:42 174

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除