
CodeForces
文章平均质量分 73
Mr_Treeeee
这个作者很懒,什么都没留下…
展开
-
CodeCraft-19 and Codeforces Round #537 (Div. 2)
http://codeforces.com/contest/1111 A. Superhero Transformation:给你两个字符串,问你S1能不能变到S2.元音可以变任意元音,辅音可以变任意辅音。变化的次数不限。wa点:长度不同。 #include<iostream>#include<math.h>#include<stri...原创 2019-02-09 11:00:34 · 336 阅读 · 0 评论 -
Codeforces Round #459 (Div. 2) - D. MADMAX (记忆化搜索)
http://codeforces.com/contest/918/problem/D题意:在一个DAG图上,每条边都有一个权值,A先走,B后走。每次走的时候,当前走的边的权值不能小于上次(A或者B都算)走的。无路可走则输。输出每一种可能的答案。POINT:dp[200][110][110];//前一条边值、【当前】先走的人所在的顶点、【当前】后原创 2018-01-31 14:33:51 · 314 阅读 · 0 评论 -
Codeforces Round #459 (Div. 2) - C. The Monster(贪心)
http://codeforces.com/contest/918/problem/C题意:给你一串?(),让你求有几组[l,r],l-r中的括号是匹配的。POINT:2 ≤ |s| ≤ 5000,可以遍历l,然后往前判断是否匹配。遇"(" , now++. ")",now--.先把"?"全部当成")",然后当temp如果没有?了那就break了。原创 2018-01-31 14:22:24 · 291 阅读 · 0 评论 -
Codeforces Round #452 (Div. 2) - C. Dividing the numbers (思路)
C. Dividing the numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya has n integers: 1, 2, 3, ...,原创 2017-12-18 22:42:39 · 352 阅读 · 0 评论 -
Codeforces Round #452 (Div. 2) - B. Months and Years(暴力)
B. Months and Yearstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEverybody in Russia uses Gregorian calen原创 2017-12-18 22:40:30 · 305 阅读 · 0 评论 -
Codeforces Round #451 (Div. 2) - D. Alarm Clock(贪心)
D. Alarm Clocktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEvery evening Vitalya sets n alarm clocks to原创 2017-12-18 22:34:32 · 504 阅读 · 0 评论 -
Codeforces Round #451 (Div. 2) - C. Phone Numbers (map+string)
C. Phone Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has several phone books, in which he原创 2017-12-18 22:31:39 · 270 阅读 · 0 评论 -
Codeforces Round #451 (Div. 2) - B. Proper Nutrition (扩展欧几里得)
B. Proper Nutritiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has n burles. One bottle of Ber-Co原创 2017-12-18 22:30:21 · 409 阅读 · 0 评论 -
Codeforces Beta Round #25 (Div. 2 Only) - E. Test (KMP)
E. Testtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSometimes it is hard to prepare tests for programmi原创 2017-12-07 23:10:01 · 237 阅读 · 0 评论 -
Codeforces Beta Round #25 (Div. 2 Only) - D. Roads not only in Berland (生成树)
D. Roads not only in Berlandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland Government decided to原创 2017-12-07 23:06:21 · 241 阅读 · 0 评论 -
Codeforces Beta Round #25 (Div. 2 Only) - C. Roads in Berland (最短路松弛)
C. Roads in Berlandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities numbered from 1 to n原创 2017-12-07 23:02:58 · 456 阅读 · 1 评论 -
Educational Codeforces Round 14 - D. Swaps in Permutation (优先队列+并差集)
D. Swaps in Permutationtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation of the原创 2017-11-27 10:42:23 · 295 阅读 · 0 评论 -
Codeforces Round #452 (Div. 2) - F. Letters Removing(树状数组+set)
F. Letters Removingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya has a string of lengthnconsisting of small and lar...原创 2019-03-28 16:42:32 · 648 阅读 · 0 评论 -
Codeforces Round #452 (Div. 2) - E. Segments Removal(链表+优先队列)
E. Segments Removaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has an array of integers of lengt原创 2017-12-21 23:05:16 · 407 阅读 · 0 评论 -
Codeforces Round #452 (Div. 2) - D. Shovel Sale (规律)
D. Shovel Saletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n shovels in Polycarp's shop. The i原创 2017-12-21 23:00:35 · 341 阅读 · 0 评论 -
Codeforces Round #451 (Div. 2) - E. Squares and not squares (贪心)
E. Squares and not squarestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnn and Borya have n piles with原创 2017-12-21 22:57:00 · 339 阅读 · 0 评论 -
Codeforces Round #441 (Div. 2) - A B C D
A. Trip For Meal给你3个点,和3点之间的距离,让你从一个点出发,走n-1次,求最短距离。POINT:数据很小,直接模拟,找规律做也很简单。#include #include #include #include using namespace std;int n,r,o,e; int ans=0;int f(int x){原创 2017-10-16 22:52:11 · 367 阅读 · 0 评论 -
Codeforces Beta Round #33 - D. Knights (暴力//建图+lca//bitset状态压缩)
D. Knightstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland is facing dark times again. The army of evil lord Van de Mart is going to conque...原创 2018-03-25 18:45:47 · 509 阅读 · 0 评论 -
Codeforces Beta Round #38 - E. Let's Go Rolling!
E. Let's Go Rolling!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn a number axis directed from the left rightwards, n marbles with coordinates...原创 2018-04-08 10:17:27 · 214 阅读 · 0 评论 -
Codeforces Round #536 (Div. 2)
http://codeforces.com/contest/1106A. Lunar New Year and Cross Counting:在n*n的矩阵里找一个固定的图案,n很小,暴力就行。#include<iostream>#include<vector>#include<string.h>#include<unordered_s...原创 2019-02-09 10:48:24 · 248 阅读 · 0 评论 -
Educational Codeforces Round 54 - E. Vasya and a Tree (树+树状数组)
http://codeforces.com/contest/1076/problem/E 题意:给你一棵n个点的树,以1为根。一开始n个点的权值为0,每个边的边长为1.给你m个操作,每次给v,d,x。把所有祖先是v的,且距离v不超过d的点的权值都加上x。 POINT:就是一个树上的搜索,加上树状数组(x这个点的答案是他的深度到n这些权值的和)它要存,当前状态下,操作...原创 2018-11-13 22:09:47 · 337 阅读 · 0 评论 -
Educational Codeforces Round 54 - D Edge Deletion(最短路)
http://codeforces.com/contest/1076/problem/D题意:给你一张图,起点为1,让你最多保留k条边,使得1到点i的最短路长度di【不变】的个数最多。 POINT:想一想就知道,每加一条边,就可以使一个点的最短路保持不变。所以这题就是选k条边,可以让k个点的最短路不变。具体就是跑一个最短路。每当确定一个点的最短路的时候,即vis[u...原创 2018-11-13 22:01:43 · 275 阅读 · 0 评论 -
Codeforces Round #513 - E. Sergey and Subway (树形DP)
http://codeforces.com/contest/1060/problem/E题意:问你一棵树上的所有点与点之间的距离。不过可以2步当成1步走。(跳着走)(即如果两个点隔了一个点,就连一条边)POINT:首先,如果距离为偶数,直接除2,如果距离为奇数,除2+1。 算出所有点与点之间的距离(不跳的真实距离)。树形DP解决。可以算每条边被走了几次,边(u,...原创 2018-10-07 19:51:08 · 443 阅读 · 0 评论 -
Codeforces Round #510 (Div. 2) - D. Petya and Array (树状数组+离散化)
http://codeforces.com/contest/1042/problem/D题意:给你n个数,询问你区间和小于t的个数。POINT:即sum[r]-sum[l-1]<t的(r,l)的对数(r>l)。可以用逆序对的做法。把sum数组离散化之后。每次sum[i]去找>sum[i]-t的前缀和的个数。 别忘记了sum[0]=0. ...原创 2018-09-27 22:03:17 · 247 阅读 · 0 评论 -
Codeforces Round #510 (Div. 2) - C. Array Product
http://codeforces.com/contest/1042/problem/C题意:给你一个n个数的序列。两种操作。1.选择序号i,j,去掉a[i],让a[j]=a[i]*a[j]。这个操作可以无限次。2.选择序号i,去掉a[i]。进过n-1次操作,只会剩下一个数,让这个数最大。 POINT:如果负数是奇数个,那么绝对值最小的负数可以单独去掉,(如果有0,...原创 2018-09-27 21:57:32 · 223 阅读 · 1 评论 -
Codeforces Round #512 (Div. 2) - D. Vasya and Triangle (皮克公式)
http://codeforces.com/contest/1058/problem/D 题意:在x [0,n]. y[0,m]的坐标系中,找到一个格点三角形(三角形的顶点全在格点上),他的面积是n*m/k. POINT:皮克定理是指一个计算点阵中顶点在格点上的多边形面积公式,该公式可以表示为2S=2a+b-2,其中a表示多边形内部的点数,b表示多边形边界上的点数,S表示多...原创 2018-09-27 21:52:04 · 278 阅读 · 0 评论 -
Educational Codeforces Round 51 (Rated for Div. 2) - F. The Shortest Statement (树上距离查询+最短路)
http://codeforces.com/contest/1051/problem/F题意:给你n个点,m条边。m-n<=20。保证图连通。问你任意两点的最短距离是多少。 POINT:由图连通可知,这个图是 在生成树的基础上加了m-(n-1)条边。然后问你距离。在HDU多校做过一道类似的。是不过只增加了一条边。即m=n。那么我们只要考虑两种情况:1.在树上的...原创 2018-09-23 10:43:59 · 287 阅读 · 0 评论 -
Codeforces Round #467 (Div. 2) - E. Lock Puzzle(构造)
http://codeforces.com/contest/937/problem/E 题意:给你一个shift(x)操作:把最后x个字符倒一下,提到最前面。问你如何从S到T。操作不能超过6100。 POINT:用三个shitf操作,可以把某个位置的数提到最前面(且他前面的数顺序保持不变)。要把第i个数提到最前面。操作是. shift(n),shift(i-1),s...原创 2018-09-30 20:33:09 · 226 阅读 · 0 评论 -
Codeforces Round #467 (Div. 2) - D. Sleepy Game (找环)
http://codeforces.com/contest/937/problem/D题意:给你一个有向图,A和B博弈,从一个S起点开始走,谁不能走了谁就输了。B睡着了,A替B走。所以B可以很蠢。如果A不能赢,那么看看A能不能使游戏永远进行下去。否则只能输了。 POINT:要赢肯定是有一条路径,走到尾的时候刚好是奇数步。没有这种路径,就从S开始找能不能进入一个环...原创 2018-09-30 20:29:22 · 271 阅读 · 0 评论 -
Codeforces Round #498 (Div. 3) - F Xor-Paths (折半搜索)
题目 题意:给你一个n*m的矩阵,从(1,1)到(n,m)只能往右或者往下走,把路径的值全部异或起来,若等于k,则算作一条路径。问你有几条路径。 POINT:反搜一半得到DP[x][y][mod]的值,代表若走到xy这个点,值为mod对答案有多少贡献。然后正搜到xy。折半搜索。注意x+y/2=1的情况。起点为(1,1) x+y=2。 #i...原创 2018-07-17 13:31:55 · 216 阅读 · 0 评论 -
Educational Codeforces Round 47 - E. Intercity Travelling
题目题意:司机不休息的话,走1公里,消耗a1,再走一公里消耗a2,然后a3、a4。这样消耗下去。有休息站,可以让a数组重新数。问你总消耗的期望*2^(n-1)。 POINT:可以推一下。px为x这个坐标的期望组成。p1=1*a1 (第一个永远是a1)p2=1/2*a1+1/2*a2 (2这个点,有1/2的概率有休息站,那么1/2*a1,有1/2没有,那么从...原创 2018-07-16 20:30:14 · 267 阅读 · 0 评论 -
Codeforces Round #287 (Div. 2) - D. The Maths Lecture (数位DP)
D. The Maths Lecturetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAmr doesn't like Maths as he finds it really boring, so he usually sleeps in Ma...原创 2018-04-20 21:57:28 · 227 阅读 · 0 评论 -
Codeforces Round #287 (Div. 2) - E. Breaking Good (SPFA)
E. Breaking Goodtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBreaking Good is a new video game which a lot of gamers want to have. There is a c...原创 2018-04-20 21:53:45 · 203 阅读 · 0 评论 -
Codeforces Round #106 (Div. 2) - D. Coloring Brackets(区间DP)
D. Coloring Bracketstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce Petya read a problem about a bracket sequence. He gave it much thought bu...原创 2018-05-01 13:42:13 · 255 阅读 · 0 评论 -
School Team Contest #1 - E. What Has Dirichlet Got to Do with That? (DFS博弈)
E. What Has Dirichlet Got to Do with That?time limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputYou all know the Dirichlet principle, the point of which ...原创 2018-04-18 10:27:30 · 200 阅读 · 0 评论 -
Codeforces Round #245 (Div. 1) - B. Working out (线性DP)
B. Working outtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSummer is coming! It's time for Iahub and Ia原创 2017-10-24 21:35:21 · 308 阅读 · 0 评论 -
Codeforces Round #393 (Div. 2) - C. Pavel and barbecue
C. Pavel and barbecuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPavel cooks barbecue. There are n ske原创 2017-10-14 18:03:05 · 404 阅读 · 0 评论 -
Codeforces Round #393 (Div. 2) - B. Frodo and pillows(模拟)
B. Frodo and pillowstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn hobbits are planning to spend the nig原创 2017-10-14 17:56:05 · 649 阅读 · 0 评论 -
Educational Codeforces Round 29 - B. Kayaking
B. Kayakingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVadim is really keen on travelling. Recently he原创 2017-10-02 20:20:37 · 720 阅读 · 0 评论 -
Educational Codeforces Round 29 - A. Quasi-palindrome
A. Quasi-palindrometime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet quasi-palindromic number be such num原创 2017-10-02 20:17:17 · 684 阅读 · 0 评论