自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

WZJRJ28

为了看到更大的世界

  • 博客(44)
  • 收藏
  • 关注

原创 Gym 100801G Graph(贪心构造)

题意:给n个点m条边的DAG,最多可以添加k条边,问添加后的图的最小拓扑序的最大值是多少。分析:开两个set,一个维护当前入度为0的所有点,一个用来维护需要被加边的点,然后对于第一个set中值最小的点,如果set中还有其他点且k还没用完,那么我们便直接把它扔进第二个set中待处理,否则直接将其打印出;如果第一个set中只有这一个点,我们便考虑能不能从第二个set中找一个最大的点

2016-08-29 21:28:21 631

原创 Gym 100886J Sockets(二分+贪心)

Valera has only one electrical socket in his flat. He also has m devices which require electricity to work. He's got n plug multipliers to plug the devices, the i-th plug multiplier has ai socke

2016-08-29 21:18:58 539

原创 Gym 100886G Maximum Product(搜索)

G. Maximum Producttime limit per test1 secondmemory limit per test256 mebibytesinputstandard inputoutputstandard outputFind the number from the range [a, b] which has the

2016-08-29 21:11:33 424

原创 UVALive 7414 Sibling Rivalry

题意:n个点m条边的有向图,有一个起点和一个终点,每次兄贵选择从abc三个数中选择一个数作为你前进的步数,问兄贵最多选择多少次你一定可以到达终点,如果无论如何都到大不了终点则输出IMPOSSIBLE.分析:假设最多需要k步我们一定可以到达终点,那么对于k-1步来说,他下一步走a,b,c步一定都可以到达终点,同理,k-2步的点下一步走a,b,c步一定可以到达k-1步的点,所以我们可以做n

2016-08-28 14:18:36 504

原创 UVALive 7416 Bringing Order to Disorder(搜索)

题意:给你一个n位”数“(前导0也算数字),问小于它的数字有多少,其中小于号重载为:1.a各个位上的数字和小于b.2.1相等的前提下a各个位上的数字+1相乘小于b.3.1,2相等的前提下a的十进制意义小于b。分析:

2016-08-28 00:27:50 571

原创 Gym 100818B Tree of Almost Clean Money

题意:给你一棵树,每次一个操作,修改书上最多不超过1000个点的值,然后询问u到v路径上的权值和。分析:树链剖分,后边单点修改区间查询可以用树状数组。#include#include#include#include#include#include#include#include#define INF 0x3f3f3f3f#define MOD 100000

2016-08-27 20:30:41 551

原创 Spoj 375 QTREE(树链剖分)

DescriptionYou are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3...N-1.We will ask you to perfrom some instructions of the following form:

2016-08-22 23:56:58 337

原创 LA 7344 Numbered Cards(数位DP)

题意:给定n,选择一些小于等于n的数构成一个集合,使得集合内各个元素的十进制表示形式没有重叠的数字,问这样的集合有多少个。分析:一共十个数字,我们可以枚举单个数字的所有组合情况(一千种),然后用数位DP求出符合每种组合的所有单个数字的个数,设f[x]表示数字集合为x的个数,我们可以利用用状压DP的方式求出f[x]的值。#include#include#include#

2016-08-22 14:31:02 375

原创 LA 7339 Owllen(贪心)

题意:给定一个长度为n的字符串(26个小写字母),让你再构造一个长度为n的字符串,使得两串的LCS最小。分析:选原串中出现次数最少的字母构造就可以了,可以证明这样一定是LCS最小。#include#include#include#include#include#include#include#include#include#include#include

2016-08-22 14:24:03 339

原创 Codeforces Round #368 (Div. 2) D. Persistent Bookcase(离线)

D. Persistent Bookcase time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRecently in school Alina has learned what are

2016-08-21 12:16:59 402

原创 LA 7231 Odd Cycle(有向图奇环)

题意:给你一个有向图,让你输出其中的一个奇环。分析:一开始想的先求出强连通分量然后二分图染色,然后发现搞不动,后来想到可以拆点,每个点拆成两个点,分别表示奇数访问和偶数访问,然后一遍DFS,开一个栈保留当然栈中的点,如果栈中同时出现了一个点的奇状态和偶状态,那么一定找到了一个奇环,输出就可以了。#include#include#include#include#inc

2016-08-20 18:27:56 2021

原创 Hdu-4507 吉哥系列故事——恨7不成妻(数位DP)

Description  单身!   依然单身!   吉哥依然单身!   DS级码农吉哥依然单身!   所以,他生平最恨情人节,不管是214还是77,他都讨厌!      吉哥观察了214和77这两个数,发现:   2+1+4=7   7+7=7*2   77=7*11   最终,他发现原来这一切归根到底都是因为和7有关!所以,他现在甚至讨厌一切和7

2016-08-19 21:32:56 355

原创 Hdu-5863 cjj's string game(矩阵快速幂)

Problem Descriptioncjj has k kinds of characters the number of which are infinite. He wants to build two strings with the characters. The lengths of the strings are both equal to n.cjj also de

2016-08-19 19:33:19 639

原创 Bzoj-1799 self 同类分布(数位DP)

Description给出a,b,求出[a,b]中各位数字之和能整除原数的数的个数。 InputOutputSample Input10 19Sample Output3HINT【约束条件】1 ≤ a ≤ b ≤ 10^18SourceDay1分析:数位DP,枚举一下所有数字之和。#include

2016-08-17 23:57:24 591

原创 Hdu-3709 Balanced Number(数位DP)

DescriptionA balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. W

2016-08-17 22:24:03 253

原创 LA 7464 Robots(贪心)

题意:有X和Y两类机器人各n m个,现在要将所有机器人上的信息传送到基点Base.同一时刻每个机器人(包括Base)只能发给一个对象,也只能接受一个对象的信息.X类的机器人发送数据的时间是x,Y类的是y. (x 分析:f(n,m) = f(n,(m-n)/2) + y (m >= n)            f(n,m) = f((n-m)/(pow(2,y/x)) + m,0

2016-08-17 21:39:16 367

原创 LA 7457 Discrete Logarithm Problem(shank的大步小布算法)

题意:求a^x % p = b的最小x。#include#include#include#include#include#include#include#include#include #include#include#include#include#define INF 0x3f3f3f3f#define eps 1e-9#define MAXN 10

2016-08-17 21:17:00 735

原创 Poj-3252 Round Numbers(数位DP)

DescriptionThe cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Scissors', 'Ro, Sham, Bo', and a host of other names) i

2016-08-16 23:22:41 520

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

Problem DescriptionAlice 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 number

2016-08-16 22:10:58 447

原创 Hdu-5845 Best Division (trie+DP)

Problem DescriptionYou are given an array A, consisting of N integers.You are also given 2 integers K and L.You must divide the whole array A into exactly K nonempty intervals, such that the

2016-08-16 18:03:57 807 2

原创 Hdu-4734 F(x)(数位DP)

Problem DescriptionFor a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1. Now you are given two numbers A and B

2016-08-16 00:25:32 297

原创 Hdu-2089 不要62(数位DP)

Problem Description杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。不吉利的数字为所有含有4或62的号码。例如:62315 73418 88914都属于不吉利号码。但是,61152虽然含有6和

2016-08-15 23:39:43 222

原创 Hdu-5834 Magic boy Bi Luo with his excited tree(树形DP)

Problem DescriptionBi Luo is a magic boy, he also has a migic tree, the tree has N nodes , in each node , there is a treasure, it's value is V[i], and for each edge, there is a cost C[i], wh

2016-08-15 20:38:02 656

原创 Hdu-5833 Zhu and 772002(高斯消元)

Problem DescriptionZhu and 772002 are both good at math. One day, Zhu wants to test the ability of 772002, so he asks 772002 to solve a math problem.But 772002 has a appointment with his girl

2016-08-14 21:43:51 421

原创 LA 7324 Promotions(bitset)

题意:给你一个SAG,你可以选一个点,但拓扑序在其后的点也要选,让你选a和b个点,问有哪些点必须被选中,最后还问了选b个点哪些一定不被选中。分析:比赛时写了n^2的暴力跑过了,正解是BITSET压缩一下一个点的前驱集合和后驱集合。#include#include#include#include#include#include#include#include#

2016-08-14 00:49:52 258

原创 Ural 2041 Nanomatryoshkas(贪心)

Matryoshka is a traditional Russian recursive doll. But everything changes, and even matryoshka needs a little innovation.Due to the use of new materials, it became possible to make a matryoshka arbit

2016-08-12 16:39:52 319

原创 Hdu-5828 Rikka with Sequence(线段树)

Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:Yuta has an array A with n number

2016-08-11 23:14:54 358

原创 Hdu-5821 Ball(贪心)

Problem DescriptionZZX has a sequence of boxes numbered 1,2,...,n. Each box can contain at most one ball.You are given the initial configuration of the balls. For 1≤i≤n, if the i-th bo

2016-08-11 21:36:17 440

原创 Hdu-5765 Bonds(状压)

Problem DescriptionGiven an undirected connected graph with N points and M edges. ?? wants to know the number of occurrence in all bonds of graph for every edge.The index of points starts from 0.A

2016-08-11 01:02:54 318

原创 LA 7334 Kernel Knights

题意:有2*n个骑士(二分图),要求你求一个集合,这个集合内的所有点之间没有边,且这个集合连出去的所有边能覆盖住出去这个集合外的所有点。分析:我们把最左边的点全部加入这个集合,然后把所有没有覆盖到的点都加入队列,然后依次处理队列中的元素,队列中的元素都要冲新加入集合,且它们连出的点都一定不再集合中,那么去除这些点又会新产生一些点没有被覆盖,我们再把它们加入队列依次循环。。。

2016-08-10 23:16:37 605

原创 Hdu-5816 Hearthstone(状态压缩DP)

Problem DescriptionHearthstone is an online collectible card game from Blizzard Entertainment. Strategies and luck are the most important factors in this game. When you suffer a desperate situation

2016-08-09 22:37:56 555 2

原创 Uva 10972 RevolC FaeLoN(边双连通分量)

题意:给定一个无向图,要求把所有的无向边改成有向边,并且添加最少的有向边使得新图强连通。分析:

2016-08-09 10:55:02 372

原创 Ural 2037. Richness of binary words (打表+构造)

DescriptionFor each integer i from 1 to n, you must print a string si of length n consisting of letters ‘a’ and ‘b’ only. The string si must contain exactly i distinct palindrome substrings. Two sub

2016-08-08 14:02:24 359

原创 Ural 2045 Richness of words(构造)

045. Richness of wordsTime limit: 0.5 secondMemory limit: 64 MBFor each integer i from 1 to n, you must print a stringsi of length n consisting of lowercase Latin letters.The stringsi

2016-08-07 20:56:32 500 2

原创 Ural 2038 Minimum Vertex Cover(二分图最小顶点覆盖+快速读入)

题意:给你一个二分图,让你把二分图中的点划分为三个集合:一定在最小顶点覆盖集中,一定不在,可能在。分析:若一个匹配点和一个未匹配点之间有边,那这个匹配点一定在最小顶点覆盖集中,它的另一个匹配点一定不再其中,一个一定不再其中的点连向的所有点都一定给在最小顶点覆盖集中,我们可以就这样DFS一遍求出所有结果。#include#include#include#include#inc

2016-08-07 20:14:57 741 2

原创 LA 3514 The Ministers' Major Mess(2-SAT)

题意: n 个人对m个方案投票 。 每个人最多对4个方案投票, 问是否存在一种决定  , 使每个人都有超过一半的建议被采用 。 且哪些方案的态度是确定的。分析:投票数#include#include#include#include#include#include#include#include#include#include#include#inc

2016-08-07 02:36:21 565

原创 Uva 11294 Wedding(2-SAT)

题意:有n对夫妻参加婚宴,所有人坐在餐桌的左侧或右侧,一对夫妻不能坐在同侧,m对吵架的人也不能坐在同侧,求方案。分析:

2016-08-06 23:49:14 281

原创 Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum

Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integersa1, a2, ..., an ofn elements!Mishka loved the array an

2016-08-05 23:00:52 274

原创 Uva 10765 Doves and bombs (点双联通分量 + Block Forest Data Structure)

题意:给定一个n个点的连通无向图,一个点的鸽子值定义为将它从图中删去后的连通块个数。求每个点的鸽子值。分析:删除后影响图连通性的点一定是割点,在求出所有双联通分量后重新构图,每个联通分量添加一个虚点,把连通分量的每个点向虚点连边,然后我们就得到了一个和原图连通性一样的森林(Block Forest Data Structure),Block Forest Data Structure森

2016-08-04 00:43:59 563

原创 Uva 11396 Claw Decomposition(二分图判断)

题意:给出一个n个节点的简单无向图,每个点的度数为3,你的任务是判断能否把它恰好分解成若干个爪,你的分解方案中,每条边必须恰好属于一个爪,但一个点可以出现在多个爪里。分析:稍微分析一下我们发现,只有二分图能符合条件。#include#include#include#include#include#include#include#include#i

2016-08-03 22:31:08 333

空空如也

空空如也

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

TA关注的人

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