自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(47)
  • 资源 (1)
  • 收藏
  • 关注

转载 图论500题

=============================以下是最小生成树+并查集======================================  【HDU】  1213        How Many Tables         基础并查集★  1272        小希的迷宫           基础并查集★  1325&&poj1308   Is It A

2017-07-26 13:11:29 632

原创 POJ-1019 Number Sequence(思维题)

A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2...Sk. Each group Sk consists of a sequence of positive integer numbers ranging from 1 to k, written one after another.

2017-07-31 21:21:55 720

原创 Codeforces-557D Vitaly and Cycle(二分图染色)

After Vitaly was expelled from the university, he became interested in the graph theory.Vitaly especially liked the cycles of an odd length in which each vertex occurs at most once.Vitaly was wondering how to solve the following problem. You are given an

2017-07-31 17:55:20 404

原创 HDU-4686 Arc of Dream(推公式+矩阵快速幂)

An Arc of Dream is a curve defined by following function: where a 0 = A0 a i = a i-1*AX+AY b 0 = B0 b i = b i-1*BX+BY What is the value of AoD(N) modulo 1,000,000,007?

2017-07-30 20:15:13 335

原创 HDU-2389 Rain on your Parade(二分图之Hopcroft-Karp算法)

You’re giving a party in the garden of your villa by the sea. The party is a huge success, and everyone is here. It’s a warm, sunny evening, and a soothing wind sends fresh, salty air from the sea. The evening is progressing just as you had imagined. It co

2017-07-30 14:23:04 338

原创 LightOJ-1296 Again Stone Game(SG打表找规律)

Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the game and they alternate moves. In each move, a player has to select any pile and should remove at least one and no more than ha

2017-07-29 11:14:23 328

原创 HDU-1045 Fire Net(简单缩点+最大匹配)

Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to shoot. The four o

2017-07-28 23:40:28 396

原创 HDU-6040 Hints of sd0061 - 2017 Multi-University Training Contest - Team 1(快排思想STL应用)

sd0061, the legend of Beihang University ACM-ICPC Team, retired last year leaving a group of noobs. Noobs have no idea how to deal with mm coming contests. sd0061 has left a set of hints for them. There are nn noobs in the team, the ii-th of which has a

2017-07-28 15:49:48 271

原创 QDU-帅气的HYC与N皇后(最大独立集)

你一定听说过N皇后问题吧。但是帅气的HYC已经开始厌倦这古老的题目了。所以他设计了新的问题——N骑士问题。这个问题跟N皇后很类似,同样是在国际象棋的棋盘上,只是把皇后(Queen)换成了 骑士(Knight ♞),就相当于中国象棋里的马了(所以说还是叫马好了~),不过要特别注意的一点是,国际象棋里的马是不会被绊马腿的(如果你不知道我在说什么,请忽略这句,并看下一段,这并不影响你解决这个问题)。HYC会给出一个n行m列棋盘,你需要往棋盘上尽量放置更多的Knight,并保证他们无法相互攻击。下图

2017-07-27 11:59:49 419

原创 最小点覆盖集之例题

POJ-3041 Asteroids题意:给一个N*N的矩阵,一些星球位于一些点上,要求消除所有星球,每次操作可消除一行或一列的星球,求最少要几次。思路:以行和列为点,星球所在行和列的关系建边,建完图之后就会发现求最小点覆盖集。代码1:#include #include using namespace std;const int maxn = 505;int G

2017-07-26 20:44:54 1510

原创 HDU-6034 Balala Power! - 2017 Multi-University Training Contest - Team 1(贪心)

Talented Mr.Tang has nn strings consisting of only lower case characters. He wants to charge them with Balala Power (he could change each character ranged from a to z into each number ranged from 0 to 25, but each two different characters should not be cha

2017-07-26 01:02:00 377

原创 HDU-6038 Function - 2017 Multi-University Training Contest - Team 1(构造置换或强连通分量)

You are given a permutation aa from 00 to n−1n−1 and a permutation bb from 00 to m−1m−1. Define that the domain of function ff is the set of integers from 00 to n−1n−1, and the range of it is the set of integers from 00 to m−1m−1. Please calculate the quan

2017-07-26 00:45:32 389

原创 HDU-6033 Add More Zero - 2017 Multi-University Training Contest - Team 1(水之崩心态题)

There is a youngster known for amateur propositions concerning several mathematical hard problems. Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between 00

2017-07-25 19:01:42 693

原创 HDU-3749 Financial Crisis(并查集+点双连通分量)

Because of the financial crisis, a large number of enterprises go bankrupt. In addition to this, other enterprises, which have trade relation with the bankrup enterprises, are also faced with closing down. Owing to the market collapse, profit decline and f

2017-07-24 22:22:41 540

原创 POJ-2135 Farm Tour(费用流)

When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of which contains his house and the Nth of which contains the big barn. A total M (1 <= M <= 10000) paths that conn

2017-07-24 14:12:58 278

原创 HDU-3829 Cat VS Dog(最大独立集及对题目的分析)

The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-animal and a dislike-animal, if the child's like-animal is a cat, then his/hers dislike-animal must be a dog, and vice versa. Now the zoo administrator is r

2017-07-23 20:42:38 677 2

原创 POJ-1466 Girls and Boys(最大独立集)

n the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically involved" is defined between one girl and one boy. For the study reasons it is necessary to find out the maximum set sat

2017-07-23 19:37:03 434

原创 最小路径覆盖问题求解及与最小边覆盖的区别

Air Raid + Treasure Exploration最小边覆盖:最小路径覆盖:有向无环图->二分图传递闭包

2017-07-22 23:57:32 4162 1

原创 POJ-1149 PIGS(最大流)

Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come to the farm one after another. Each of them has keys to some pig-houses and wants to buy a certain number of

2017-07-22 14:16:24 312

原创 输入输出外挂

当然输入输出外挂一般用在大量输入输出的情况下,这样性价比才高一些,否则得不偿失(牺牲了代码长度而换来了微不足道的效率提升)。

2017-07-21 23:57:00 436

原创 HDU-5647 DZY Loves Connecting(树形dp)

DZY has an unrooted tree consisting of nn nodes labeled from 11 to nn. DZY likes connected sets on the tree. A connected set SS is a set of nodes, such that every two nodes u,vu,v in SS can be connected by a path on the tree, and the path should only cont

2017-07-19 23:21:30 298

原创 POJ-1698 Alice's Chance(最大流)

Alice, a charming girl, have been dreaming of being a movie star for long. Her chances will come now, for several filmmaking companies invite her to play the chief role in their new films. Unfortunately, all these companies will start making the films at t

2017-07-19 18:42:15 347

原创 hihoCoder 最大权闭合子图

在一个图中,我们选取一些点构成集合,记为V,且集合中的出边(即集合中的点的向外连出的弧),所指向的终点(弧头)也在V中,则我们称V为闭合图。最大权闭合图即在所有闭合图中,集合中的点的权值之和最大的V,我们称V为最大权闭合图。(可抽象为最大权密闭图求法的题一般是含有一些点具有一定的利益收入,另一些点具有一定的利益支出,即每个点都有一个权值。拥有某个具有收入效益的点前提是必须得拥有一些具有一定利益

2017-07-18 19:29:22 824

原创 HDU-5787 K-wolf Number(数位DP)

Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation of x is pairwised different. Given (L,R,K), please count how many K-wolf numbers in range of L,RL,R.InputThe input contains multiple test cases. There are

2017-07-17 19:21:52 371

原创 POJ-3683 Priest John's Busiest Day(2-SAT问题)

John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the couple who get married on that day will be forever blessed by the God of Love. This year N couples plan to get marrie

2017-07-17 13:42:46 277

原创 2-SAT问题

2-SAT问题SAT问题即适定性问题:是否可以确定一个满足所有条件的方案。SAT问题的表述:有若干个集合,每个集合里有若干个元素,每个集合只能选择一个,然后再给出一些取元素的规则,问能否可行,能则给出一个可行方案。在所有集合中,元素个数最多的集合的元素个数为k个,则就称为K-SAT问题。所以2-SAT问题就是k=2时的情况,而当k>2时的情况已经被证明为NP完全问题。学习资料:

2017-07-16 01:20:55 836

原创 Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)-831C Jury Marks(思维)

Jury MarksPolycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one a

2017-07-14 23:59:55 384

原创 HDU-3191 How Many Paths Are There(有向图次短路条数)

oooccc1 is a Software Engineer who has to ride to the work place every Monday through Friday. For a long period, he went to office with the shortest path because he loves to sleep late…Time goes by, he find that he should have some changes as you could see

2017-07-14 17:25:06 373

原创 POJ-3255 Roadblocks(次短路)

Bessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the scenery along the way. She has decided to take the second-shortest rather than the

2017-07-13 23:45:36 599

原创 HDU-1688 Sightseeing(最短路+次短路)

Tour operator Your Personal Holiday organises guided bus trips across the Benelux. Every day the bus moves from one city S to another city F. On this way, the tourists in the bus can see the sights alongside the route travelled. Moreover, the bus makes a n

2017-07-13 23:06:54 485

原创 Floyd算法求无向图最小环

There is a travel agency in Adelton town on Zanzibar island. It has decided to offer its clients, besides many other attractions, sightseeing the town. To earn as much as possible from this attraction, the agency has accepted a shrewd decision: it is neces

2017-07-13 01:19:02 6465

原创 POJ-1651 Multiplication Puzzle(区间dp)

he multiplication puzzle is played with a row of cards, each containing a single positive integer. During the move player takes one card out of the row and scores the number of points equal to the product of the number on the card taken and the numbers on

2017-07-12 17:44:03 279

原创 HDU-5115 Dire Wolf(区间dp)

Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not all, Dire Wolves appear to originate from Draenor.Dire wolves look like normal wolves, but these creatures are of nearly twice the size. These powerful bea

2017-07-12 16:55:28 381

原创 POJ-2449 Remmarguts' Date(A*算法+SPFA求第K短路)

"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story. "Prince Remmarguts lives in his kingdom UDF – United Delta of Freedom. One day their neighboring coun

2017-07-12 00:25:16 582

原创 Floyd 算法求多源最短路径-打印最短路径

通过一个nex数组来记录路径,nex[i][j]表示从i到j的最短路径从i开始走的第一个点。这样整个最短路径中的nex[i][j]都是这个含义,则就表示出了最短路径。#include using namespace std;const int maxn = 1005;int mp[maxn][maxn], nex[maxn][maxn];int n, m;void init(){

2017-07-11 17:15:28 2058

原创 HDU-3068 最长回文(manacher算法)

题意:给一个字符串s,求最长回文串的长度。思路:manacher算法模板题,点击入门。Code(板子):#include #include #include using namespace std;const int maxn = 110005;char s[maxn*2];int p[maxn*2];int manacher(){ int id, maxle

2017-07-11 15:13:00 282

原创 ZJC-1489 L先生与质数V4 51Nod-1184 第N个素数 (大区间求素数个数模板+二分)

Description在解决了上一个质数问题之后,L先生依然不甘心,他还想计算下更多范围内的质数,你能帮助他吗?(没错这题题面和V3一毛一样)Input有多组测试例。(测试例数量<70)每个测试例一行,输入一个数字n(0<n<=3000000),输入0表示结束。Output输出测试例编号和第N个质数。Case X: YSample Input1234101000Sample OutputCase 1: 2Case 2: 3Case 3: 5Case 4: 7Case

2017-07-11 01:19:44 527

原创 ZOJ-3645 BiliBili(高斯消元)

Shirai Kuroko is a Senior One student. Almost everyone in Academy City have super powers, and Kuroko is good at using it. Her ability is "Teleporting", which can make people to transfer in the eleven dimension, and it shows like moving instantly in general

2017-07-10 23:51:14 283

原创 高斯消元模板

高斯消元模板

2017-07-10 23:40:48 242

原创 SHU-丢史蒂芬妮(博弈NP状态交替)

有一天,空和白很无聊,决定玩盛大游戏,考虑到两个人玩,他们随便掏了一个游戏出来:在一个n∗m 的棋盘上,首先把史蒂芬妮·多拉放在左上角(1,1) 的位置。每次一个人可以将她往下,往右,往右下丢一格。当前回合,谁不能丢史蒂芬妮,谁就输了。(注意,不可以把活人丢出棋盘啦!)游戏总是空先手。白说,这是一个垃圾游戏!我们每次把史蒂芬妮丢素数个位置吧!(换句话说,每次丢2 或3 或5 或7 或…格)空答应了。我们都知道,空和白都很聪明,不管哪方存在一个可以必胜的最优策略,都会按照最优策略保证胜利。玩了一局

2017-07-10 10:25:56 629

我的ACM个人模板模板

自己整理了很久的模板,继续加油~

2018-05-23

空空如也

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

TA关注的人

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