codeforces
xiao_you_you
这个作者很懒,什么都没留下…
展开
-
C. Prefixes and Suffixes (codefoces)
Ivan wants to play a game with you. He picked some string原创 2018-12-19 13:05:48 · 953 阅读 · 0 评论 -
Minimal Segment Cover(1175E) 倍增
You are given原创 2019-06-14 10:59:07 · 260 阅读 · 0 评论 -
C. Beautiful Lyrics (CodeForces)
You are given原创 2019-06-14 20:20:44 · 246 阅读 · 0 评论 -
E. Product Oriented Recurrence(矩阵快速幂)
Let原创 2019-06-16 00:20:07 · 264 阅读 · 0 评论 -
C2. Exam in BerSU (hard version)
The only difference between easy and hard versions is constraints.If you write a solution in Python, then prefer to send it in PyPy to speed up execution time.A session has begun at Beland State U...原创 2019-06-22 12:16:05 · 560 阅读 · 0 评论 -
D. Extra Element
A sequence原创 2019-06-22 12:22:19 · 393 阅读 · 0 评论 -
E. Polycarp and Snakes
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size原创 2019-06-24 16:52:25 · 230 阅读 · 0 评论 -
C. Vasya And Array(Codeforces1187)
思路:对于每一段连续且满足操作为1 的区间 设为相同的数,不相邻的区间之间设为递减的数。 #include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include<map>#include<cstring&...原创 2019-07-03 11:28:45 · 316 阅读 · 1 评论 -
D. Subarray Sorting(线段树 )codeforces1187
思路:用一个队列aa存一下a数组中每一个数的位置。我们遍历数组b去找aa[b[i]].front(表示数b[i]在a第一个出现的位置),找从1到该位置的最小值是否是b[i],若不是 则为no,若是则将 改位置的数组a的数赋值成inf 以更新该区间最小值。就这样 一直找下去。。#include <iostream>#include <cstring>#inclu...原创 2019-07-03 11:35:18 · 309 阅读 · 2 评论 -
E. Tree Painting(换根)
#include <iostream>#include <vector>#include <cstring>#define ll long longusing namespace std;vector<int> g[1008611];int v;int n,siz[1008611];ll up[1008611], sum[10086...原创 2019-07-03 11:51:10 · 445 阅读 · 1 评论 -
D1. Submarine in the Rybinsk Sea (easy edition)
思路:每个第k位(从1开始)都会恰好在2k和2k−1位各贡献n次#include <iostream>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <cmath>#include<strin...原创 2019-07-18 11:35:07 · 182 阅读 · 0 评论 -
Flood Fill CodeForces - 1114D
You are given a line ofnncolored squares in a row, numbered from11tonnfrom left to right. Theii-th square initially has the colorcici.Let's say, that two squaresiiandjjbelong to the same...原创 2019-04-19 16:43:30 · 167 阅读 · 0 评论 -
C. Colorful Bricks(dp)
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.There are原创 2019-04-17 19:55:51 · 306 阅读 · 0 评论 -
CodeForces - 859C. Pie Rules(思维+dp)
You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which ...原创 2019-04-17 17:41:18 · 337 阅读 · 0 评论 -
E - Bank Hacking CodeForces - 796C
Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has ...原创 2019-01-17 21:54:53 · 136 阅读 · 0 评论 -
C. Banh-mi(前缀和+快速幂)
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.F...原创 2019-01-14 12:55:08 · 689 阅读 · 0 评论 -
E. Polycarp's New Job
Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.Berland bills somehow come in lots of different sizes. However, all of the...原创 2019-01-14 15:29:02 · 218 阅读 · 0 评论 -
F. Tree with Maximum Cost
You are given a tree consisting exactly of原创 2019-01-21 15:12:47 · 340 阅读 · 1 评论 -
D. Balanced Ternary String
You are given a string $$$s$$$ consisting of exactly $$$n$$$ characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.Your task is to replace minimum number ...原创 2019-01-21 15:17:59 · 298 阅读 · 0 评论 -
C. Ayoub and Lost Array(dp)
Ayoub had an array aa of integers of size nn and this array had two interesting properties:All the integers in the array were between ll and rr (inclusive). The sum of all the elements was divisibl...原创 2019-01-26 11:27:28 · 235 阅读 · 0 评论 -
C. Palindromic Matrix(codeforces)
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For e...原创 2019-02-20 12:29:21 · 443 阅读 · 0 评论 -
Two Cakes(codeforces)1030B
Sasha and Dima want to buy two原创 2019-03-03 15:21:29 · 382 阅读 · 0 评论 -
C. Neko does Maths(code forces)
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.Neko has two integers原创 2019-04-26 09:56:24 · 727 阅读 · 0 评论 -
Keiichi Tsuchiya the Drift King Gym - 102028D
Drifting is a driving style in which the driver uses the throttle, brakes, clutch, gear shifting and steering input to keep the car in a state of oversteer while manoeuvring from turn to turn. As a sp...原创 2019-04-17 16:17:30 · 347 阅读 · 0 评论 -
codeforces161D. Distance in Tree(树形DP)
思路:dp[i][j]表示点 i 的子节点到点 i 的距离为j的路径个数。设一点为u,其子节点为v, u、v间的边权值为w转移方程为:dp[u][j]+=dp[v][j-1];每个点对答案的贡献为:ans+=dp[u][j]*dp[v][(k-1-j)];#include <iostream>#include<cstdio>#include<c...原创 2019-10-08 10:24:40 · 108 阅读 · 0 评论