自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

tomjobs的博客

I was so much older then, I'm younger than that now.

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

原创 Complete Tripartite CodeForces - 1228D(三分图染色)

You have a simple undirected graph consisting of n vertices and m edges. The graph doesn’t contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected...

2019-09-30 17:43:58 667

原创 BZOJ1003 [ZJOI2006] 物流运输trans(spfa + dp)

题目描述物流公司要把一批货物从码头A运到码头B。由于货物量比较大,需要n天才能运完。货物运输过程中一般要转停好几个码头。物流公司通常会设计一条固定的运输路线,以便对整个运输过程实施严格的管理和跟踪。由于各种因素的存在,有的时候某个码头会无法装卸货物。这时候就必须修改运输路线,让货物能够按时到达目的地。但是修改路线是—件十分麻烦的事情,会带来额外的成本。因此物流公司希望能够订一个n天的运输计划,使...

2019-09-30 14:26:46 211

原创 bzoj1601[Usaco2008 Oct]灌水(最小生成树)

展开题目背景John的农场缺水了!!!题目描述Farmer John has decided to bring water to his N (1 <= N <= 300) pastures which are conveniently numbered 1…N. He may bring water to a pasture either by building a well...

2019-09-30 10:40:24 227

原创 CF1228C. Primes and Multiplication(数学)

Let’s introduce some definitions that will be needed later.Let ????????????????????(????) be the set of prime divisors of ????. For example, ????????????????????(140)={2,5,7}, ????????????????????(169)={13}.Let ????(????,????) be the maximum possible int

2019-09-30 10:06:11 1017

原创 cf1228B B. Filling the Grid

Suppose there is a ℎ×???? grid consisting of empty or full cells. Let’s make some definitions:???????? is the number of consecutive full cells connected to the left side in the ????-th row (1≤????≤ℎ). In particular...

2019-09-30 10:04:10 390

原创 cf1228AA. Distinct Digits

A. Distinct Digitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have two integers ???? and ????. Find an integer ???? which satisfies the conditi...

2019-09-30 10:02:33 401

原创 F - Free Weights Gym - 101170F(二分)

NWERC 2016Problem F Free WeightsThe city of Bath is a noted olympic training ground—bringing local, national, and even in- ternational teams to practice. However, even the finest gymnasium falls vic...

2019-09-29 20:47:50 295

原创 C - Careful Ascent Gym - 101170C(推公式)

NWERC 2016Problem C Careful AscentThat went well! As police sirens rang out around the palace, Mal Reynolds had already reached his lifting device outside of the city.No spaceship can escape Planet...

2019-09-29 19:58:52 408

原创 H - Hamiltonian Hypercube Gym - 101170H(格雷码转二进制)

NWERC 2016Problem H Hamiltonian HypercubeHypercube graphs are fascinatingly regular, hence you have devoted a lot of time studying the mathematics related to them. The vertices of a hypercube graph ...

2019-09-29 18:59:54 426

原创 E - Exam Redistribution Gym - 101170E(排序)

NWERC 2016Problem E Exam RedistributionLinda is giving an exam. When the exam is over, Linda will redistribute the exams among the students for a peer review, so they may grade each other’s answers ...

2019-09-29 18:48:25 323

原创 I - Iron and Coal Gym - 101170I(多源最短路)

NWERC 2016Problem I Iron and CoalThere are many excellent strategy board games, and your favourite among them is called “Steel Age”. It offers many different paths to victory but you prefer the bloo...

2019-09-29 12:52:54 296

原创 H - Hotel POJ - 3667(区间合并)

The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent, has named the Bul...

2019-09-28 22:10:13 213

原创 POJ2382 Stars in Your Window AcWing 248. 窗内的星星(扫描线)

Description在一个天空中有很多星星(看作平面直角坐标系),已知每颗星星的坐标和亮度(都是整数)。求用宽为W、高为H的矩形窗户(W,H为正整数)能圈住的星星的亮度总和最大是多少。(矩形边界上的星星不算)Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you...

2019-09-28 09:32:26 615

原创 二分的mid取法

有两个二分写法r = mid, l = mid + 1, m = (l + r) >> 1.当答案要对mid的浮点结果向上取整的时候这样取。如最少几个人可以分完果子,二分人数。r = mid - 1, l = mid, m = (l + r + 1) >> 1.当答案要对mid的浮点结果向下取整的时候这样取。如最多需要几个果子分配给所有人,二分果子数。...

2019-09-27 22:58:42 834

原创 Anadi and Domino CodeForces - 1230C(dfs)

Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1≤a≤b≤6, there is exactly one domino with a dots on one half and b dots on the ot...

2019-09-27 21:34:47 298

原创 收集果子(树形dp)

题意: 给你一棵树,1为根节点,每个节点有果子数,每个节点的权值为其子树果子的和。问多少种删边的方式,使得1节点的权值为k。思路: 组成k的种类数??不就是多少种方法组成某个面值吗,可以想到是树上背包。定义f(i,j)为递归到第i个节点收集了j个果子的方案数。那么有两种子状态:(1)把(u,v)边断了,那么结果乘上p(size(u)-1) X f(u,i)。p(i)代表2的i次方。(2)加上以v...

2019-09-27 21:31:31 518

原创 F - Physical Education Lessons CodeForces - 915E(离散化线段树)

This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend phys...

2019-09-26 21:31:26 177

原创 G - Tunnel Warfare HDU - 1540(线段树区间合并,最长连续01)

During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except t...

2019-09-23 14:59:09 240

原创 D - Infinite Inversions CodeForces - 540E(离散化树状数组)

There is an infinite sequence consisting of all positive integers in the increasing order: p = {1, 2, 3, …}. We performed n swap operations with this sequence. A swap(a, b) is an operation of swapping...

2019-09-22 13:59:36 172

原创 F - Parentheses Gym - 101987F(表达式解析,链表)

Problem FParentheses Time Limit: 1 SecondThe correspondence among the operators and the operands can be clarified using parentheses. In a C program, for example, the expression a-b-c can be clarifie...

2019-09-21 23:42:34 459

原创 A - Ultra-QuickSort OpenJ_Bailian - 2299(离散化求逆序对/归并排序)

In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted i...

2019-09-20 21:25:08 361

原创 Perfect Team CodeForces - 1221C(二分/推公式)

C. Perfect Teamtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou may have already known that a standard ICPC team consists of exactly three...

2019-09-20 20:48:42 770

原创 D. Make The Fence Great Again(二维dp)

D. Make The Fence Great Againtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a fence consisting of ???? vertical boards. The width of e...

2019-09-20 19:07:20 1412

原创 Knights CodeForces - 1221B

B. Knightstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a chess board with ???? rows and ???? columns. Initially all cells of the bo...

2019-09-20 18:40:09 839

原创 2048 Game CodeForces - 1221A

A. 2048 Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing a variation of game 2048. Initially you have a multiset ???? of ???? int...

2019-09-20 18:34:39 501

原创 ACWING306. 杰拉尔德和巨型象棋(组合数DP)

给定一个 H*W 的棋盘,棋盘上只有 N 个格子是黑色的,其他格子都是白色的。在棋盘左上角有一个卒,每一步可以向右或向下移动一格,并且不能移动到黑色格子中。求这个卒从左上角移动到右下角,一共有多少种路线。输入格式第一行包含三个整数H,W,N。接下来N行,每行包含两个整数x,y,描述一个黑色格子位于x行y列。数据保证左上角和右下角的格子都是白色的。输出格式输出一个整数表示结果对109...

2019-09-19 13:06:38 213

原创 ACWING366. 看牛(欧拉回路)

给定N个点M条边的无向图,求一条路径,从节点1出发,最后回到节点1,并且满足每条边恰好被沿着正、反两个方向分别经过一次。若有多种方案,输出任意一种即可。输入格式第一行包含两个整数N和M。接下来M行每行包含两个整数a和b,表示点a和点b之间存在一条边。输出格式共2M+1行,每行包含一个整数,共同描述除了满足条件的一条路径。数据范围1≤N≤104,1≤M≤5∗104输入样例:4 ...

2019-09-18 20:32:23 249

原创 ACWING 364. 网络(lca+tarjan求双连通分量缩点)

给定一张N个点M条边的无向连通图,然后执行Q次操作,每次向图中添加一条边,并且询问当前无向图中“桥”的数量。输入格式输入包含多组测试数据。每组测试数据,第一行包含两个整数N和M。接下来M行,每行包含两个整数A和B,表示点A和点B之间有一条边,点的编号为1~N。接下来一行,包含整数Q。在接下来Q行,每行包含两个整数A和B,表示在A和B之间加一条边。当输入0 0时表示输入终止。输出格式...

2019-09-17 18:03:04 236

原创 ACWING363. B城(tarjan求割点)

B城有 n 个城镇,m 条双向道路。每条道路连结两个不同的城镇,没有重复的道路,所有城镇连通。把城镇看作节点,把道路看作边,容易发现,整个城市构成了一个无向图。输入格式第一行包含两个整数 n 和 m。接下来m行,每行包含两个整数 a 和 b,表示城镇 a 和 b 之间存在一条道路。输出格式输出共n行,每行输出一个整数。第 i 行输出的整数表示把与节点 i 关联的所有边去掉以后(不去...

2019-09-17 17:56:59 310

原创 算法杂谈

1.总感觉tarjan和并查集异曲同工。tarjan妙就妙在追溯值low数组,有了这个数组,那么如果我们遍历x点的子树时,最终遍历回了x点,那么就会使得low[v] = low[x] = dfn[x],最终能够连在一起能够任意到达的一坨点的low[v]都会变成dfn[x](因为是递归遍历到最深层,先算最深,如果能算到x,那么一开始出发的x点的dfn[x]肯定最小,那全变成了这玩意),low[x]最...

2019-09-16 23:55:23 178

原创 Electricity POJ - 2117(tarjan求割点)

Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of them supplying a small area that surrounds it. This organization ...

2019-09-14 23:09:54 616

原创 SPF POJ - 1523(tarjan求割点,求连通分量数)

Consider the two networks shown below. Assuming that data moves around these networks only between directly connected nodes on a peer-to-peer basis, a failure of a single node, 3, in the network on th...

2019-09-14 22:05:52 263

原创 lca倍增和离线tarjan模板

https://www.luogu.org/problem/P3379#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 1e6 + 7;int head[maxn],to[maxn],nex[maxn],d[max...

2019-09-14 11:55:38 210

原创 Lost Cows POJ - 2182 ACWING244. 谜一样的牛(树状数组+二分/倍增)

有n头奶牛,已知它们的身高为 1~n 且各不相同,但不知道每头奶牛的具体身高。现在这n头奶牛站成一列,已知第i头牛前面有Ai头牛比它低,求每头奶牛的身高。输入格式第1行:输入整数n。第2…n行:每行输入一个整数Ai,第i行表示第i头牛前面有Ai头牛比它低。(注意:因为第1头牛前面没有牛,所以并没有将它列出)输出格式输出包含n行,每行输出一个整数表示牛的身高。第i行输出第i头牛的身高...

2019-09-11 20:52:44 436

原创 树状数组区间更新区间查询模板

现在还没看懂,先记录下来#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int SIZE=100010;int a[SIZE],n,m;long long c[2][SIZE],sum[SI...

2019-09-11 10:32:57 163

原创 ACWING241. 楼兰图腾(树状数组,三元上升组计数)

在完成了分配任务之后,西部314来到了楼兰古城的西部。相传很久以前这片土地上(比楼兰古城还早)生活着两个部落,一个部落崇拜尖刀(‘V’),一个部落崇拜铁锹(‘∧’),他们分别用V和∧的形状来代表各自部落的图腾。西部314在楼兰古城的下面发现了一幅巨大的壁画,壁画上被标记出了N个点,经测量发现这N个点的水平位置和竖直位置是两两不同的。西部314认为这幅壁画所包含的信息与这N个点的相对位置有关,...

2019-09-10 23:57:37 176

原创 ACWING246. 区间最大公约数(线段树差分)

给定一个长度为N的数列A,以及M条指令,每条指令可能是以下两种之一:1、“C l r d”,表示把 A[l],A[l+1],…,A[r] 都加上 d。2、“Q l r”,表示询问 A[l],A[l+1],…,A[r] 的最大公约数(GCD)。对于每个询问,输出一个整数表示答案。输入格式第一行两个整数N,M。第二行N个整数A[i]。接下来M行表示M条指令,每条指令的格式如题目描述所示。...

2019-09-10 20:14:11 303

原创 ACWING245. 你能回答这些问题吗(线段树区间合并)

给定长度为N的数列A,以及M条指令,每条指令可能是以下两种之一:1、“1 x y”,查询区间 [x,y] 中的最大连续子段和,即 maxx≤l≤r≤y{∑ri=lA[i]}。2、“2 x y”,把 A[x] 改成 y。对于每个查询指令,输出一个整数表示答案。输入格式第一行两个整数N,M。第二行N个整数A[i]。接下来M行每行3个整数k,x,y,k=1表示查询(此时如果x>y,请...

2019-09-10 16:15:47 296

原创 Mondriaan's Dream POJ - 2411(轮廓线dp 状压dp)

Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his ‘toilet series’ (where he had to use his toilet paper to draw on, for all of h...

2019-09-09 23:29:10 1394

原创 Travelling HDU - 3001(三进制状态压缩,旅行商问题)

After coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does not mind which city being...

2019-09-08 23:18:45 266

空空如也

空空如也

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

TA关注的人

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