E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
#Codeforces
Codeforces
275D Zero Tree 树形DP+贪心
点击打开链接题意:n个结点的树,每个结点有权值v[i],操作:选以1为根的子树,使子树上的点全部+1/-1.nusingnamespacestd;typedeflonglongll;constintN=2e5+20;constllmod=1e9+7;vectore[N],tmp,t;lln,a[N],deg[N],fa[N];llsum[N];//sum[u]uµ½rootËùÔÚµÄÁ´±»²Ù
Masamiiiii
·
2020-09-14 18:34
CODEFORCES_
Dynamic
Programming
Codeforces
796D Police Stations 构造+BFS
点击打开链接题意:n个点的树,k个为黑色,law:任意点距离d内都有黑点,n,k,dv,若v已经被某个黑点访问过,则v,u的最小距离黑点不是同一个,u-v可以删除#includeusingnamespacestd;constintN=6e5+20;typedefpairii;intn,k,d,ans;vectore[N];//toidqueueq;//u,fromintvis[N],mk[N];v
Masamiiiii
·
2020-09-14 18:34
CODEFORCES_
Constructive
&
BruteForce
Codeforces
831D Office Keys 二分+贪心
题意:n个人在一条直线上,有终点p和k把钥匙,每把钥匙只能拿一次.n,kusingnamespacestd;typedeflonglongll;typedefpairii;constintN=2e3+20;lln,k,p,vis[N];lla[N],b[N];vectorseg;boolcheck(llx){seg.clear();for(inti=1;ix)returnfalse;lladd=(
Masamiiiii
·
2020-09-14 18:34
CODEFORCES_
Binary
Search
&&
Greedy
CodeForces
1047C思维
题意:Mr.Fhasnnpositiveintegers,a1,a2,…,an.Hethinksthegreatestcommondivisoroftheseintegersistoosmall.Sohewantstoenlargeitbyremovingsomeoftheintegers.Butthisproblemistoosimpleforhim,sohedoesnotwanttodoitb
ivan_zcy
·
2020-09-14 18:02
codeforces
743D Chloe and pleasant prizes 树形dp
D.Chloeandpleasantprizestimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputGeneroussponsorsoftheolympiadinwhichChloeandVladiktookpartallowedalltheparticipantst
Marcus-Bao
·
2020-09-14 18:29
树形dp
codeforces
Codeforces
Global Round 3
A.AnotherOneBitesTheDusttimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputLet’scallastringgoodifandonlyifitconsistsofonlytwotypesofletters—‘a’and‘b’andeverytwo
MekakuCityActors
·
2020-09-14 18:29
Codeforces
754 D Fedor and coupons
D.Fedorandcouponstimelimitpertest4secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputAllourcharactershavehobbies.ThesameistrueforFedor.Heenjoysshoppingintheneighboringsupermark
HandsomeHow
·
2020-09-14 18:57
数据结构
codeforces
743 A Vladik and flights(水题)
A.Vladikandflightstimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputVladikisacompetitiveprogrammer.ThisyearheisgoingtowintheInternationalOlympiadinInformatics
HandsomeHow
·
2020-09-14 18:57
杂题
codeforces
743 B Chloe and the sequence(递归)
B.Chloeandthesequencetimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputChloe,thesameasVladik,isacompetitiveprogrammer.Shedidn'thaveanyproblemstogettotheolympia
HandsomeHow
·
2020-09-14 18:57
杂题
Sonya and Queries
CodeForces
- 713A [字典树] 好题~
A.SonyaandQueriestimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputTodaySonyalearnedaboutlongintegersandinvitedallherfriendstosharethefun.Sonyahasaninitiallyem
Conchpeng
·
2020-09-14 18:56
数据结构之字典树
Codeforces
611C:New Year and Domino 二维前缀和
CF上10^8并不会超时(TL为1S)题目大意:在给定的n,m的矩阵中问在以l1,r1,l2,r2为边界的矩阵1*2的骨牌有多少种不同的放法。思路:看了题解才知道这是一种二维前缀和--。放骨牌的话只有两种放法横着和竖着。那么可以设两个二维数组分别装横与竖着的前缀数组。然后再枚举两个符合的区间。#include#include#include#include#include#include#incl
Grit_ICPC
·
2020-09-14 18:54
普通DP
Educational
Codeforces
Round 46 (Rated for Div. 2)
Educational
Codeforces
Round46(RatedforDiv.2)http://
codeforces
.com/contest/1000A.CodehorsesT-shirtshttps
bryce1010
·
2020-09-14 18:23
Codeforces
803C Maximal GCD
链接http://
codeforces
.com/problemset/problem/803/C题目大意给你两个数nk,让你求一个恰好含有k个数的严格上升数列,使得∑ai=n。且这个数列的gcd最大。
*ACoder*
·
2020-09-14 18:22
贪心
二分答案
Codeforces
274B 【树形DP】
题目大意给定一棵树,以及树上每个点的权值,每次操作可以将一棵含有节点1的联通子集上的所有的点权全部加1或减1,求最少几次操作可以将树上全部点权变为0根据题意,设1点为树根,这样对每个点修改时,一定也会修改其父节点,因为它的父节点是通往(1号点/树根)的必经之路这样的话就是YY一个使得总操作次数最少的方法了。如果我们能够把几个个点权值变为0的过程合为同一次操作,那样次数就会变少,如果说一个点有多个儿
Zolrk
·
2020-09-14 18:22
NOIP
动态规划
Educational
Codeforces
Round 30 C. Strange Game On Matrix
C.StrangeGameOnMatrixProblemStatementIvanisplayingastrangegame.Hehasamatrixawithnrowsandmcolumns.Eachelementofthematrixisequaltoeither0or1.Rowsandcolumnsare1-indexed.Ivancanreplaceanynumberofonesinthi
Effervescence
·
2020-09-14 18:51
codeforces
Educational
Codeforces
Round 26 E. Vasya's Function(数论)
传送门:点击打开链接E.Vasya'sFunctiontimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputVasyaisstudyingnumbertheory.Hehasdenotedafunctionf(a, b)suchthat:f(a, 0) = 0;f(a,
Ever_glow
·
2020-09-14 18:51
******CF******
******数论******
ACM的进阶之路
CodeForce题解
Maximal GCD
CodeForces
- 803C
emmm求一个数n大于k的最小约数这样的问题,如果不暴力的话其实可以用欧拉筛法的思想遍历n的素因子,每个素因子求一个约数这样去弄,会比直接暴力省时间。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing
Electrodeless_key
·
2020-09-14 18:51
gcd构造
Codeforces
Round #198 (Div. 2) E. Iahub and Permutations
题目描述:戳这里题解:这题是一道组合+递推题。首先直接错排是不行的,因为有一些位置上原来与它配对的点已经被其它某一个点占用了,所以要重新思考。既然有这种占用的情况,我们注意到有几个点被占用了,那么原本与占用这个点的位置配对的点就空下来了。我们可以将它们先补到那些被占用点的位置上去。我们假设这些点的个数为sumx,那么剩下的没有任何限制条件又未被占用的点的个数,我们设为sumy。那么就可以递推一下了
DYT_B
·
2020-09-14 18:49
题解
CodeForces题解
Codeforces
Round #562 (Div. 2) E. And Reachability(dp)
题目n(n0,则称i到j是可达的,igo[x][k]->y,可达;所有都不符合,则不可达心得开始WA了一发,注意初始化感觉自己思维题还是练的不够吧但所幸现在能照着turorial大致敲出来,码力还凑活相信随着积累应该是可以渐渐培养思维的代码#includeusingnamespacestd;constintmaxn=3e5+10;constintlg=20;intgo[maxn][lg],last
Code92007
·
2020-09-14 18:47
#
Infinite Inversions
CodeForces
- 540E (树状数组+离散化)
题目链接题目大意,在一串无穷的1,2,3…n的串值,有k次操作,每次操作给出两个数a,b,即把坐标a和坐标b的值交换,问最后有多少个逆序对,0#include#include#include#includeusingnamespacestd;structnode{intl,r;}sw[100005];//存交换intid[400005];//离散化intf[400005];//每个离散化后的点的权
coldfresh
·
2020-09-14 18:47
codeforces
离散化
树状数组
Codeforces
Round #111 (Div. 2) D.Edges in MST(最小生成树+桥 MST必要边/可行边/不可行边)
题目n(nusingnamespacestd;constintN=1e5+10;#definepbpush_back#definefifirst#definesesecond#definesci(a)scanf("%d",&(a))#definerep(i,a,b)for(inti=(a);iP;structedge{intu,v,w,id;booloperatore[N];intfind(int
Code92007
·
2020-09-14 18:17
#
#
Tarjan/2-sat
最小生成树
必要边
桥
双连通分量
不必要边
Codeforces
Round #548 (Div. 2) C. Edgy Trees(思维+dfs)
题目链接:https://
codeforces
.com/contest/1139/problem/C题意是给了一棵树,n个点,m条边。
Ch_zaqdt
·
2020-09-14 18:16
CodeForces
ACM_搜索
[组合]
Codeforces
#660E. Different Subsets For All Tuples
这种题做起来贼爽…套路考虑一个子序列的贡献,有个问题就是每种a串只计算一次,如何避免重复。很简单,对于一个串a,只在第一次出现这个子序列的位置算贡献。考虑一个子序列,下标分别为k1,k2,...,kt。1到k1−1不能出现ak1,k1+1到k2−1不能出现ak2,…kt+1到n随便填。也就是说有kt−t个位置有m−1种填法,n−kt个位置有m种填法。空串直接单独算,然后我们就可以列出答案的式子了:
Lynstery
·
2020-09-14 18:45
组合数学
Codeforces
Round #507 (Div. 1) B. Subway Pursuit 交互题
脑洞交互题给出范围系统会返回yesno来表示列车是不是在该范围内二分范围然后范围差不多了猜一下范围里面的一个点然后继续二分范围直到猜对注意可以用coutusingnamespacestd;typedeflonglongll;intmain(){srand(time(0));lln,k;cin>>n>>k;lll=1,r=n;stringtemp;while(1){l=max(l-k,1ll);r=
哒哒哒哒哒嘭
·
2020-09-14 18:44
ACM
Vasya And The Matrix------Educational
Codeforces
Round 48 (Rated for Div. 2)
D.VasyaAndTheMatrixtimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputNowVasyaistakinganexaminmathematics.Inordertogetagoodmark,Vasyaneedstoguessthematrixthatt
Anoyer
·
2020-09-14 18:41
题解
Codeforces
Codeforces
660E Different Subsets For All Tuples【组合数学】
题目链接:http://
codeforces
.com/problemset/problem/660/E题意:给定数字范围,问由这些数字组成的长度为n的串的子序列有多少种?
An55511
·
2020-09-14 18:41
codeforces
990D、Graph And Its Complement(思维)
D.GraphAndItsComplementtimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputGiventhreenumbersn,a,bn,a,b.Youneedtofindanadjacencymatrixofsuchanundirectedgraphthat
Amovement
·
2020-09-14 18:40
Codeforces
140CNew Year Snowmen
一道优先队列好题不难发现,每次取最多的几个雪球能保证凑出来的雪人最多,然后我们就先离散化一下,然后封装丢到优先队列里,每次取出队首的三个,将数量各自减一,表示凑了一个雪人,然后将数量大于一的再丢回去,直到剩余种数小于3为止代码//ByAcerMo#include#include#include#include#include#includeusingnamespacestd;constintM=1
AcerMo
·
2020-09-14 18:09
数据结构-堆
D. Three Sequences(思维+数学+差分维护)详解
https://
codeforces
.com/contest/1406/problem/D题意:给一段序列ai,构造一个bi和ci,使得bi+ci=ai,且bi单调不减,ci单调不增,求最小的max(bi
小菜鸡加油
·
2020-09-14 18:07
差分
思维
构造
A. Subset Mex(思维+枚举)
https://
codeforces
.com/contest/1406/problem/A思路:mexA和mexB由区间内未出现的最小的决定,从最小的0开始枚举,看看有没有出现,有出现就打个标记,累加答案
小菜鸡加油
·
2020-09-14 18:06
思维
Codeforces
Round #450 (Div. 2) D. Unusual Sequences 莫比乌斯系数容斥
D.UnusualSequencestimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputCountthenumberofdistinctsequencesa1, a2, …, an(1 ≤ ai)consistingofpositiveintegerssuchthatg
zstu_zy
·
2020-09-14 18:06
算法理解
Educational
Codeforces
Round 48 (Rated for Div. 2) D - Vasya And The Matrix (位运算构造)
原题地址:http://
codeforces
.com/contest/1016/problem/D题意:给你一个矩阵的长宽分别为n,mn,m.然后将每一行的元素全部异或起来,得到序列a,a[i]a,a[
yiqzq
·
2020-09-14 18:03
CodeForces
540E - Infinite Inversions(离散化+BIT)
题目链接https://cn.vjudge.net/problem/
CodeForces
-540E【题意】有一个无限长的序列,1,2,3,…n,n+1…,现在要将它们中的某些元素交换,问你交换后所得的序列中逆序对的总数是多少
SingleK
·
2020-09-14 18:58
CodeForces
545E - Paths and Trees(最短路树)
题目链接https://cn.vjudge.net/problem/
CodeForces
-545E【题意】给定一个n个结点m条边的无向图,并给出源点s,让你找出图中权值最小的最短路树,并输出这个权值【思路
SingleK
·
2020-09-14 18:58
CodeForces
873C(贪心)
问题描述:Ivanisplayingastrangegame.Hehasamatrixawithnrowsandmcolumns.Eachelementofthematrixisequaltoeither0or1.Rowsandcolumnsare1-indexed.Ivancanreplaceanynumberofonesinthismatrixwithzeroes.Afterthat,hiss
wust_cyl
·
2020-09-14 18:28
小技巧
CodeForces
965E Short Code (字典树的缩树)
Arkady'scodecontainsnnvariables.EachvariablehasauniquenameconsistingoflowercaseEnglishlettersonly.OnedayArkadydecidedtoshortenhiscode.Hewantstoreplaceeachvariablenamewithitsnon-emptyprefixsothatthesen
winter2121
·
2020-09-14 18:27
ACM**数据结构**
Codeforces
Round #634 (Div.3)
Codeforces
Round#634Div.3ABCDEFA题意:给两姐妹分糖,需要Alice的糖比Betty的糖多,问有多少种分法(所有糖必须分完)。
moyangxian
·
2020-09-14 17:56
codeforces
Codeforces
Round #634 (Div. 3) 题解
A.CandiesandTwoSisters查看题解数学B.ConstructtheString查看题解构造C.TwoTeamsComposing查看题解贪心D.Anti-Sudoku查看题解构造E1.ThreeBlocksPalindrome(easyversion)查看题解前后缀+暴力E2.ThreeBlocksPalindrome(hardversion)查看题解前缀+思维
忘梦心
·
2020-09-14 17:56
codeforces
Codeforces
Problemset 198E(#125 div.1 E)
问题描述在一个二维平面上,你现在的位置在(x,y)同时你手上有一块磁铁。在这个平面上,还有N块散落的磁铁,每个磁铁都可以抽象成一个点,你的目标是吸引最多的散落的磁铁。每一块磁铁都有五个属性,x,y,m,p,r,分别表示磁铁的横坐标,磁铁的纵坐标,磁铁的重量,磁铁的吸引力,磁铁的吸引半径。一块磁铁想要把另一块磁铁吸过来的条件,有两条。1.被吸引的磁铁和吸引的磁铁之间的距离小于等于吸引磁铁的吸引半径。
weixinding
·
2020-09-14 17:56
CodeForces
274 B.Zero Tree(树形dp)
B.ZeroTreeAtreeisagraphwithnverticesandexactlyn - 1edges;thisgraphshouldmeetthefollowingcondition:thereexistsexactlyoneshortest(bynumberofedges)pathbetweenanypairofitsvertices.AsubtreeofatreeTisatreew
这有点难啊
·
2020-09-14 17:25
Codeforces
1118F1 Tree Cutting (Easy Version) (DFS)
题面链接:传送门F1.TreeCutting(EasyVersion)timelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregivenanundirectedtreeofnnvertices.Someverticesarecoloredblue,somear
Lambert-O
·
2020-09-14 17:51
F1. Tree Cutting (Easy Version)
http://
codeforces
.com/contest/1118/problem/F1题意:给一棵树,有些节点是红色或蓝色,或无色,切掉一条边后分成两棵树且红蓝在不同的树;有多少条边可以切;思路:一个节点的一个子树点有么包含红的全部且不包含蓝的
newhonor
·
2020-09-14 17:51
dfs
Educational
Codeforces
Round 45 990 D. Graph And Its Complement [构造 + 图论]
D.GraphAndItsComplementtimelimitpertest:2secondsmemorylimitpertest:256megabytesinput:standardinputoutput:standardoutputGiventhreenumbersn,a,b.Youneedtofindanadjacencymatrixofsuchanundirectedgraphthatt
Whowell
·
2020-09-14 17:51
图论
Codeforces
Round #540 (Div. 3) F1. Tree Cutting (Easy Version) 【DFS】
任意门:http://
codeforces
.com/contest/1118/problem/F1F1.TreeCutting(EasyVersion)timelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregivenanundirectedtreeofnnv
weixin_30760895
·
2020-09-14 17:11
codeforces
140E.New Year Garland
传送门:解题思路:要求相邻两行小球颜色集合不同,并且限制行内小球相邻不同。由此可得:每行小球排列都是独立与外界的,所以答案应该是对于所有行的颜色集合分类,在将行内的答案乘到上面。先考虑如何分类:我们可以确定对于每行所取的颜色种类$x=|S|$,若相邻两行$i,j$,其$x_i!=x_j$,那么一定是合法的,有$C_m^x$种选择方法。而对于相邻两行$x_i=x_j$,对于行$i$的一种方案,只有一
weixin_30725315
·
2020-09-14 17:40
Codeforces
Round #100 E. New Year Garland (第二类斯特林数+dp)
题目链接:http://
codeforces
.com/problemset/problem/140/E题意:圣诞树上挂彩球,要求从上到下挂\(n\)层彩球。已知有\(m\)种颜色的球,球的数量不限。
weixin_30737433
·
2020-09-14 17:40
CodeForces
-748D 贪心
这题的思维难度不是很大,属于编程实现细节处理较多的题。暂且把每个字符串的“beauty”称为魅力值,用一个优先队列数组将同一个字符串的所有魅力值保存,通过map将不同字符串编号,就可以十分方便的查询到每个字符按串对应的魅力值队列了。之所以使用优先队列,是因为先处理魅力值更大的才能使得最后的回文串魅力值的和最大。每个字符串氛围回文串和非回文串,应该分开考虑。1.先处理非回文字符串,非回文字符串必须把
weixin_30668887
·
2020-09-14 17:40
[
codeforces
274b]Zero Tree(树形dp)
题意:给出一棵树,每个点有权值,每次操作可以对一个联通子集中的点全部加1,或者全部减1,且每次操作必须包含点1,问最少通过多少次操作可以让整棵树每个点的权值变为0.解题关键:自底向上dp,记录up,down两个数组代表u被加的次数和减的次数,以1为根,则$up[u]=\max(up[v])$$down[u]=\max(down[v])$而子树确定,该节点改变的次数也就确定了。从而推出该点的up和d
weixin_30486037
·
2020-09-14 17:38
codeforces
321# D. Kefa and Dishes (状态压缩DP)
题目:http://
codeforces
.com/contest/580/problem/D题意:有n种菜(每一种菜有一个满意值ai>=0),你准备吃m种,每种一次。
w20810
·
2020-09-14 17:33
ACM-动态规划
CodeForces
580D.Kefa and Dishes(状压DP)
D.KefaandDishestimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputWhenKefacametotherestaurantandsatatatable,thewaiterimmediatelybroughthimthemenu.Therewerendis
Usher_Ou
·
2020-09-14 17:33
CF
数据结构
状压DP
上一页
58
59
60
61
62
63
64
65
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他