自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 UVA 10129 Play on Words(并查集)

Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very imp

2018-01-31 10:43:40 434

原创 CodeForces 525D Arthur and Walls

D. Arthur and Walls time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard outputFinally it is a day when Arthur has enough money for buying a

2018-01-30 14:25:29 211

原创 Codeforces Round #459 (Div. 2) D. MADMAX

D. MADMAX time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputAs we all know, Max is the best video game player among her friends. Her

2018-01-30 12:47:54 286

原创 Codeforces Round #459 (Div. 2) C. The Monster

题目链接 C. The Monster time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputAs Will is stuck in the Upside Down, he can still communicat

2018-01-30 09:48:19 332

原创 Codeforces Round #297 (Div. 2) 525E Anya and Cubes(折半查找+map)

题目链接题意:给出n个棍子, k个魔法棒, 目标数s. 魔法棒可以使得棍子长度变为棍子长度的阶乘, 问木棒和为s的方案数.预处理求出阶乘, 根据s范围可知木棒最长是18, 而后进行dfs, dfs时, 分为三种情况, 取这根木棒, 不取这根木棒, 以及取这根木棒的阶乘. 进行两次dfs, 折半存储结果.,这次map开了两维,其实这种思想用的很多,比如区间求中位数,以后多多注意下。详

2018-01-29 17:52:37 330

原创 codeforces B. Modulo Sum

B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputYou are given a sequence of numbers a1, a2, …, an, and a number m.

2018-01-29 13:41:00 279

原创 codeforces 675D Tree Construction

又是一道用set的例题这道题用set做确实很巧妙,前后的值本想遍历做,但是会超时,用set就不会了,而且set也能用lower_bound,长知识了,然后它的父节点只和相邻值出现的次序有关,画个图就可以发现了,详见代码注释#include <bits/stdc++.h>#define ll long long#define pb push_back#define inf 0x3f3f3f3f

2018-01-27 13:25:40 180

原创 UVA 10305(拓扑排序)

简单的拓扑排序,记录一下模板吧#include #define ll long long#define pb push_back#define inf 0x3f3f3f3f#define rep(i,a,b) for(int i=a;i#define rep1(i,a,b) for(int i=a;i>=b;i--)using namespace std;const int

2018-01-26 17:26:45 172

原创 UVA 816

紫书上的题,题目链接wa的我心疼,网上也有很多误解的地方标记初始状态为0的话,那么下次搜索到这个状态就return了,但是这个状态其实并没有出现过,我们默认初始为它的下一个点的坐标,方向不变,这才是第一个达到的状态才对。大致题意 有一个最多包含9*9个交叉点的迷宫。输入起点、离开起点时的朝向和终点,求一条最短路(多解时任意输出一个即可)。详细题意请看原题难点在于转向,将四个方向和

2018-01-26 16:09:59 360

原创 Codeforces 673D Bear and Two Paths

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputBearland has n cities, numbered 1 through n. Cities are connected via bidirectional r

2018-01-26 14:55:21 200

原创 Codeforces C Graph and String

A. Graph and String time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output One day student Vasya was sitting on a lecture and mentioned a string

2018-01-26 14:30:48 202

原创 Codeforces Round #293 (Div. 2) E. Arthur and Questions

E. Arthur and Questions time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputAfter bracket sequences Arthur took up number theory. He

2018-01-25 16:51:10 135

原创 codeforces B. Duff in Love

B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputDuff is in love with lovely numbers! A positive integer x is cal

2018-01-25 08:54:20 282

原创 Codeforces C. Duff and Weight Lifting

C. Duff and Weight Lifting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputRecently, Duff has been practicing weight lifting. As a

2018-01-25 08:35:51 269

原创 codeforces567E President and Roads

题目链接题目大意:总统要回家,会经过一些街道,每条街道都是单向的并且拥有权值。现在,为了让总统更好的回家,要对每一条街道进行操作:1)如果该街道一定在最短路上,则输出“YES”。2)如果该街道修理过后,该边所在的最短路可以取代原先的最短路,则输出“CAN x”,x是修改该街道的花费,就是权值减小的值。3)如果该街道是一条不连通的街道,或者修改过后权值小于等于0,则输出“NO”。解析:需要迪

2018-01-24 20:58:42 238

原创 Tarjan算法

Tarjan 算法就是求强连通分量的算法 下面介绍几个定义 强连通图:任意两个定点之间相互可达 强连通分量:非强连通图有向图的极大强连通子图在Tarjan算法中为每个节点i维护了以下几个变量: DFN[i]:深度优先搜索遍历时节点i被搜索的次序。 low[i]:节点i能够回溯到的最早位于栈中的节点。 flag[i]:标记i是否在栈中。这个算法大致过程就是 对于每个节点每条边都要

2018-01-24 19:40:19 374

原创 Codeforces Round #321 (Div. 2) D. Kefa and Dishes

题目链接大意:题意:有n种菜(每一种菜有一个满意值ai>=0),你准备吃m种,每种一次。但是如果你按某种规则吃两种菜的话会增加额外的满意值,比如规则(xi yi ci)就是你先吃第xi个菜,然后马上吃第yi个菜,那么你就会额外增加ci点满意值。有k个这样的规则,问你吃m种菜后的最大满意值是多少。解析:一个状态压缩的dp,这里比较特殊的是每种菜都有先后关系,所以我们要记录一下上个菜选的是什么

2018-01-24 12:54:49 193

原创 UVA - 699

题目链接典型的递归写法,注意下格式#include #define ll long long#define pb push_back#define inf 0x3f3f3f3fusing namespace std;const int N=1e5+100;const int mi=N/2;int arr[N];int l,r;void build(int p){

2018-01-23 21:57:13 272

原创 CodeForces 633D Fibonacci-ish

Fibonacci-ish time limit per test 3 seconds memory limit per test 512 megabytes input standard input output standard outputYash has recently learnt about the Fibonacci sequence and is very e

2018-01-23 14:27:30 234

原创 Manthan, Codefest 16 633C Spy Syndrome 2

题目链接大意:给出一个字符串, 还原这个字符串为原句, 将此字符串拆分为一个个的单词, 如果与下面给出的m个单词相匹配, 则该单词为原句单词, 要求原字符串全部匹配.解析:dfs有两种思路:第一种代码如下#include #define ll long long#define pb push_back#define inf 0x3f3f3f3fusing namespa

2018-01-23 14:14:28 544

原创 #1688 : LR问题

时间限制:10000ms 单点时限:1000ms 内存限制:256MB描述给定两个字符串S和T,每个字符串都由’L’、’R’和’_’组成。例如:R__LR_R_L每一次操作,可以将S中的一个’R’与它右边相邻的’‘交换(前提是这个R右边相邻位置就是’‘);或者将S中的一个’L’与它左边相邻的’‘交换(前提是这个L左边相邻位置就是’‘)。例如,先移动第一个L,再移动第二个R会

2018-01-22 21:31:06 160

原创 hiho编程练习赛45

给定平面上N个点P1=(X1, Y1), P2=(X2, Y2), … PN=(XN, YN)。 请你从中找到两个不同的点Pi和Pj满足:其他所有点都在Pi和Pj连线的同一侧(可以在连线上)。如果有多组答案满足条件,你可以输出任意一组。 输入第一行包含一个整数N。 以下N行每行包含两个整数Xi和Yi。 对于50%的数据,1 ≤ N ≤ 1000 对于100%的数据,1 ≤ N ≤ 1000

2018-01-22 20:18:19 222

原创 codeforces632 E. Thief in a Shop

题目链接题目大意:从n种物品里面(每种无限个)选k个物品,打印所有可能的价值解析:每种无限个,所以可以想到完全背包,但是直接dp,恰好k次是很难控制的 所以我们可以让 每一个物品的价值减去他们的最小值,这样最小值那个物品的价值就变成了0,所以我们可以枚举每个价值(最大1e6),如果组成这个价值的件数小于等于k,剩下的就可以用最小值物品的0补齐,(这个价值+k*最小值)就是可以生成的价值

2018-01-22 18:57:20 273

原创 Educational Codeforces Round 9 D. Longest Subsequence

题目链接题目大意:找到最长的序列,使其最小公倍数小于等于m解析:这道题的关键是要对m进行枚举,找到1到m每个数及其约数的个数并记录#include #define ll long long#define pb push_back#define inf 0x3f3f3f3fusing namespace std;const int N=1e6+100;int arr[N],n

2018-01-22 18:03:38 105

原创 组合数计算代码

double lnchoose(int n, int m){ if (m > n) { return 0; } if (m 2.0) { m = n-m; } double s1 = 0; for (int i=m+1; i<=n; i++) { s1 += log(

2018-01-21 11:45:27 820

原创 Codeforces Round #457 (Div. 2) B. Jamie and Binary Sequence (changed after round)

题目大意:把n分成k个2的次方相加,注意两点:使最大值最小,然后按字典序最大的输出。 解题思路:直接看代码的注释吧#include #define ll long long#define pb push_back#define inf 0x3f3f3f3fusing namespace std;const int N=300000;int arr[N];int main()

2018-01-20 15:35:16 415

空空如也

空空如也

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

TA关注的人

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