- 博客(78)
- 收藏
- 关注
转载 Codeforces F. Maxim and Array(构造贪心)
题目描述: Maxim and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Maxim has found an array of n integers, needed by no o...
2019-08-16 19:09:00
257
转载 Codeforces A. Playlist(暴力剪枝)
题目描述: Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a playlist consisting of n songs. The -th song is characteriz...
2019-08-16 15:25:00
281
转载 Codeforces H. Kilani and the Game(多源BFS)
题目描述: Kilani and the Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kilani is playing a game with his friends. This game can be...
2019-08-16 13:57:00
319
转载 Codeforces E. High Load(构造)
题目描述: High Load time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Arkady needs your help again! This time he decided to build his own h...
2019-08-15 10:55:00
247
转载 P4781 【模板】拉格朗日插值
题目描述: 题目背景 这是一道模板题 题目描述 由小学知识可知,n个点\((x_i,y_i)\)可以唯一地确定一个多项式 现在,给定n个点,请你确定这个多项式,并将k代入求值 求出的值对998244353取模 输入格式 第一行两个正整数n,k,含义如题 接下来nnn行,每行两个正整数x_i,y_i,含义如题 输出格式 一个整数表示答案 输入输出样例 输入 #1 3 100 1 4 2 9...
2019-08-13 23:05:00
183
转载 Codeforces D. The Sum of the k-th Powers(拉格朗日插值)
题目描述: The Sum of the k-th Powers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are well-known formulas: , , . Also mathematic...
2019-08-13 21:23:00
253
转载 Codeforces G. The Brand New Function(枚举)
题目描述: The Brand New Function time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarpus has a sequence, consisting of n non-negative ...
2019-08-13 16:30:00
211
转载 Codeforces J. Sagheer and Nubian Market(二分枚举)
题目描述: Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On his trip to Luxor and Aswan, Sagheer went to a Nub...
2019-08-13 14:09:00
185
转载 Codeforces J. Soldier and Number Game(素数筛)
题目描述: Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Two soldiers are playing a game. At the beginning first...
2019-08-12 19:34:00
183
转载 Manacher算法(马拉车)求最长回文子串
Manacher算法求最长回文字串 算法思路 按照惯例((・◇・)?),这里只是对算法的一些大体思路做一个描述,因为找到了相当好理解的博客可以参考(算法细节见参考文章)。 一般而言,我们的判断回文算法的思想是从一个点开始向两边拓展直到无法拓展为止,这个时候就得到了回文串的长度,但这个算法的时间复杂度是\(O(n^2)\)的。在这个算法进行的过程中,我们有可能会不断地拓展了重复的位置而产生...
2019-08-12 11:08:00
147
转载 Codeforces A. Kyoya and Colored Balls(分步组合)
题目描述: Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kyoya Ootori has a bag with n colored balls that are co...
2019-08-11 22:12:00
235
转载 Codeforces I. Producing Snow(优先队列)
题目描述: C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice likes snow a lot! Unfortunately, this year’s winter is a...
2019-08-11 20:02:00
191
转载 Codeforces K. Ice Skating(求强连通分量)
题目描述: Ice Skating time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bajtek is learning to skate on ice. He's a beginner, so his only mo...
2019-08-11 13:53:00
264
转载 Codeforces H. Prime Gift(折半枚举二分)
题目描述: Prime Gift time limit per test 3.5 seconds memory limit per test 256 megabytes input standard input output standard output Opposite to Grisha's nice behavior, Oleg, though he has an entire ...
2019-08-11 11:35:00
238
转载 Codeforces A. Password(KMP的nxt跳转表)
题目描述: Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Asterix, Obelix and their temporary buddies Suffix and Prefix has fina...
2019-08-10 22:44:00
161
转载 Codeforces B. Bad Luck Island(概率dp)
题目描述: Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Bad Luck Island is inhabited by three kinds of species: r r...
2019-08-10 20:57:00
220
转载 Codeforces C Match Points(二分贪心)
题目描述: Match Points time limit per test 2 seconds memory limit per test 256 mega bytes input standard input output standard output You are given a set of points x1, , ..., *x**n* Two points iand j...
2019-08-10 20:35:00
236
转载 求逆元的四种算法(拓欧费马小线性推欧拉)
求逆元的四种算法 拓展欧几里得算法求逆元 上一篇博客中已经讲过拓展欧几里得算法,并且讲解了求逆元的原理。这里只列出代码 在要求逆元的数与p互质时使用 代码 //扩展欧几里得定理 int ex_gcd(int a,int b,int& x,int& y) { if(b==0) { x=1; y=0; retur...
2019-08-10 10:44:00
323
转载 扩展欧几里得算法
拓展欧几里得算法 先来看看一个重要的基本定理 裴蜀定理 对于整数a,b,他们关于x,y的线性不定方程\(ax+by=d\),设\(gcd(a,b)=g\),则可证明\(g|d\),换句话说,就是g是a,b的最小线性组合。 证明: 设\(ax+by=d\),\(g=gcd(a,b)\),设\(ax+by\)的最小值为s, \(\because\) \(g|a,g|b\) \(\theref...
2019-08-09 21:49:00
194
转载 P3376 【模板】网络最大流
题目描述: 题目描述 如题,给出一个网络图,以及其源点和汇点,求出其网络最大流。 输入格式 第一行包含四个正整数N、M、S、T,分别表示点的个数、有向边的个数、源点序号、汇点序号。 接下来M行每行包含三个正整数ui、vi、wi,表示第i条有向边从ui出发,到达vi,边权为wi(即该边最大流量为wi) 输出格式 一行,包含一个正整数,即为该网络的最大流。 输入输出样例 输入 #1 4 5 ...
2019-08-09 13:22:00
164
转载 KM(Kuhn-Munkres)算法求带权二分图的最佳匹配
KM(Kuhn-Munkres)算法求带权二分图的最佳匹配 相关概念 这个算法个人觉得一开始时有点难以理解它的一些概念,特别是新定义出来的,因为不知道是干嘛用的。但是,在了解了算法的执行过程和原理后,这些概念的意义和背后的作用就渐渐的显示出来了。因此,先暂时把相关概念列出来,看看,有个大概印象就好,等到了解了算法的流程后,在看原理中会有这些概念,那个时候回来细看就好了。 完备匹配:定义 ...
2019-08-09 12:17:00
590
转载 二分图匹配算法(最大流匈牙利)
二分图匹配 相关概念 无向二分图\(G(U\bigcup V,E)\):U是一个顶点集合,V是另一个顶点集合,对于一个集合内的点无边直接相连,而对于不同集合的点可以连边,即\((u,v)\in E\)。 匹配:两两不含公共端点的边的集合M称为匹配(就是两个集合之间连的边,只不过不同边的端点不能重合) 最大匹配:元素最多的M,即而G中两两不含公共端点的边的集合\(M\subseteq E\...
2019-08-08 20:14:00
320
转载 KMP算法模板
KMP算法模板 原理 见参考文章 模板 #include <iostream> #include <cstring> #define max_n 100005 using namespace std; char s[max_n] = {'a','a','b','a','a','a','b','c'}; char p[max_n] = {'a','a','a','b...
2019-08-08 10:16:00
92
转载 Codeforces G. Ciel the Commander
题目描述: Ciel the Commander time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Now Fox Ciel becomes a commander of Tree Land. Tree Land, lik...
2019-08-07 14:21:00
152
转载 点分治模板
点分治模板 点分治: 这里统一地,只讲一下主要思想,各种细节留给参考文章。 点分治的主要是处理树上的路径问题,如果用暴力做法求解会有很高的时间复杂度\(O(n^2)-O(n^3)\)的样子。而如果使用点分治,就可以将复杂度降为\(O(nlog_2n)\)。主要思路是将一棵树分解成若干子树,在分解成子树的子树,递归地求解出部分答案(分),最后在递归回去时合并答案(治)。至于怎么分解树,这里...
2019-08-07 10:38:00
144
转载 Codeforces I. Vessels(跳转标记)
题目描述: Vessels time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There is a system of n vessels arranged one above the other as shown in...
2019-08-06 17:37:00
177
转载 Codeforces C. Maximum Value(枚举二分)
题目描述: Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a sequence a consisting of n integers. Find the maxi...
2019-08-06 13:29:00
197
转载 Codeforces D. Little Elephant and Interval(思维找规律数位dp)
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant very much loves sums on interv...
2019-08-06 11:10:00
275
转载 [USACO15DEC]最大流Max Flow(树上差分)
题目描述: Farmer John has installed a new system of N−1N-1N−1 pipes to transport milk between the NNN stalls in his barn (2≤N≤50,0002 \leq N \leq 50,0002≤N≤50,000), conveniently numbered 1…N1 \ldots ...
2019-08-04 21:45:00
162
转载 Codeforces E. Alyona and a tree(二分树上差分)
题目描述: Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona has a tree with n vertices. The root of the tree is th...
2019-08-04 20:07:00
217
转载 倍增法求lca(最近公共祖先)
倍增法求lca(最近公共祖先) 基本上每篇博客都会有参考文章,一是弥补不足,二是这本身也是我学习过程中找到的觉得好的资料 思路: 大致上算法的思路是这样发展来的。 想到求两个结点的最小公共祖先,我们可以先把两个的深度提到同一水平,在一步一步往上跳,直到两个结点有了一个公共祖先,依照算法流程,这就是least common ancestor。 但是如果这样一步步地往上未免太让人着急,为了提...
2019-08-04 19:32:00
223
转载 Codeforces C. Jzzhu and Cities(dijkstra最短路)
题目描述: Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities number...
2019-08-04 11:08:00
208
转载 Codeforces B. Mouse Hunt(强连通分解缩点)
题目描述: Mouse Hunt time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Medicine faculty of Berland State University has just finished their...
2019-08-03 19:42:00
253
转载 Tarjan算法分解强连通分量(附详细参考文章)
Tarjan算法分解强连通分量 算法思路: 算法通过dfs遍历整个连通分量,并在遍历过程中给每个点打上两个记号:一个是时间戳,即首次访问到节点i的时刻,另一个是节点u的某一个祖先被访问的最早时刻。 时间戳用DFN数组存储,最早祖先用low数组来存,每次dfs遍历到一个节点u,即让这两个记号等于当前时刻,在后面回溯或者判断的过程中在来更新low,DNF是一定的,因为第一次访问时刻一定。然后...
2019-08-03 19:41:00
182
转载 Codeforces A. Game on Tree(期望dfs)
题目描述: Game on Tree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Momiji has got a rooted tree, consisting of n nodes. The tree nodes...
2019-08-03 11:21:00
239
转载 链式前向星
链式前向星 在之前先来看一下边集数组。 边集数组是图的表示法的一种,前向星是边集数组的一种,链式前向星是前向星的一种。 前向星 前向星是把边的起点从小到大排序,起点一样按同样的规则排终点。所以前向星使用之前要\(O(nlog_2n)\)排序一下。 使用两个数组,一个head,head[i]记录以i为起点的边在边的数组里面的第一个位置,一个len,len[i]记录以 i为起点的边有多少条。...
2019-08-03 11:21:00
200
转载 Codeforces G. Bus Number(dfs排列)
题目描述: Bus Number time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This night wasn't easy on Vasya. His favorite team lost, and he didn'...
2019-08-03 11:20:00
260
转载 Codeforces H. Malek Dance Club(找规律)
题目描述: Malek Dance Club time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As a tradition, every year before IOI all the members of Natali...
2019-08-03 11:20:00
262
转载 Codeforces I. Inna and Nine(组合)
题目描述: Inna and Nine time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Inna loves digit 9 very much. That's why she asked Dima to write a...
2019-08-03 11:19:00
230
转载 Codeforces J. Monotonic Renumeration(组合)
题目描述: You are given an array consisting of nmonotonic renumeration as an array b consisting of \(n\)integers such that all of the following conditions are met: b1=0; for every pair of indices ia...
2019-08-03 11:17:00
182
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅