![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
codeforces
刷题后日常写题解
Elige?
学校 浙江财经大学
专业 计算机科学与技术(19级)
ACM铜牌
展开
-
D. Add to Neighbour and Remove (枚举)
Polycarp was given an array of a[1…n] of n integers. He can perform the following operation with the array a no more than n times:Polycarp selects the index i and adds the value ai to one of his choice of its neighbors. More formally, Polycarp adds the va原创 2020-12-16 11:52:05 · 732 阅读 · 0 评论 -
E2. Close Tuples (hard version)(组合数)
链接https://codeforces.com/contest/1462/problem/E2This is the hard version of this problem. The only difference between the easy and hard versions is the constraints on k and m. In this version of the problem, you need to output the answer by modulo 109+7.原创 2020-12-16 11:49:37 · 476 阅读 · 0 评论 -
CF 1462 简单的题解
A. Favorite SequencePolycarp has a favorite sequence a[1…n] consisting of n integers. He wrote it out on the whiteboard as follows:he wrote the number a1 to the left side (at the beginning of the whiteboard);he wrote the number a2 to the right side (at原创 2020-12-16 01:12:57 · 677 阅读 · 3 评论 -
B. Find the Spruce(递推)
Holidays are coming up really soon. Rick realized that it’s time to think about buying a traditional spruce tree. But Rick doesn’t want real trees to get hurt so he decided to find some in an n×m matrix consisting of “" and “.”.To find every spruce first原创 2020-12-12 22:17:31 · 431 阅读 · 1 评论 -
CF1450 C1. Errich-Tac-Toe (Easy Version) C2. Errich-Tac-Toe (Hard Version)(构造)
链接 https://codeforces.com/contest/1450/problem/C2The only difference between the easy and hard versions is that tokens of type O do not appear in the input of the easy version.Errichto gave Monogon the following challenge in order to intimidate him from原创 2020-12-08 20:02:12 · 51714 阅读 · 0 评论 -
CF1450 D. Rating Compression(贪心+stl)
链接 https://codeforces.com/contest/1450/problem/DOn the competitive programming platform CodeCook, every person has a rating graph described by an array of integers a of length n. You are now updating the infrastructure, so you’ve created a program to comp原创 2020-12-08 19:48:08 · 310 阅读 · 0 评论 -
CF 1453 C. Triangles(枚举)
Gildong has a square board consisting of n rows and n columns of square cells, each consisting of a single digit (from 0 to 9). The cell at the j-th column of the i-th row can be represented as (i,j), and the length of the side of each cell is 1. Gildong l原创 2020-12-04 23:44:29 · 633 阅读 · 0 评论 -
CF 1455 E. Four Points(模拟加枚举)
链接 https://codeforces.com/problemset/problem/1455/EYou are given four different integer points p1, p2, p3 and p4 on XY grid.In one step you can choose one of the points pi and move it in one of four directions by one. In other words, if you have chosen p原创 2020-12-01 11:31:44 · 1652 阅读 · 4 评论 -
CF1455 D. Sequence and Swaps(模拟)
链接 https://codeforces.com/contest/1455/problem/DYou are given a sequence a consisting of n integers a1,a2,…,an, and an integer x. Your task is to make the sequence a sorted (it is considered sorted if the condition a1≤a2≤a3≤⋯≤an holds).To make the seque原创 2020-12-01 01:03:09 · 499 阅读 · 0 评论 -
CF1455 B. Jumps(思维)
链接 https://codeforces.com/contest/1455/problem/BYou are standing on the OX-axis at point 0 and you want to move to an integer point x>0.You can make several jumps. Suppose you’re currently at point y (y may be negative) and jump for the k-th time. Yo原创 2020-12-01 01:00:52 · 436 阅读 · 0 评论 -
Educational Codeforces Round 99 A到E题解
链接 https://codeforces.com/contest/1455A. Strange FunctionsLet’s define a function f(x) (x is a positive integer) as follows: write all digits of the decimal representation of x backwards, then get rid of the leading zeroes. For example, f(321)=123, f(12原创 2020-12-01 00:57:32 · 490 阅读 · 0 评论 -
CF1457 C. Bouncing Ball
链接 https://codeforces.com/contest/1457/problem/CC. Bouncing BallYou’re creating a game level for some mobile game. The level should contain some number of cells aligned in a row from left to right and numbered with consecutive integers starting from 1, a原创 2020-11-29 19:18:53 · 271 阅读 · 0 评论 -
CF 1457 B. Repainting Street(暴力模拟)
B. Repainting Street链接 https://codeforces.com/contest/1457/problem/BThere is a street with n houses in a line, numbered from 1 to n. The house i is initially painted in color ci. The street is considered beautiful if all houses are painted in the same co原创 2020-11-29 19:14:43 · 334 阅读 · 0 评论 -
2020ICPC·小米 网络选拔赛第一场 J.Matrix Subtraction (二维差分)
链接:https://ac.nowcoder.com/acm/contest/7501/J?&headNav=acmGiven a matrix M of size n×m and two integers a, b , determine weither it is possible to make all entrys of M zero by repeatedly choosing a\times ba×b submatrices and reduce the values in the c原创 2020-11-26 20:58:49 · 99 阅读 · 0 评论 -
CF 1451 D. Circle Game
链接 https://codeforces.com/contest/1451/problem/DUtkarsh is forced to play yet another one of Ashish’s games. The game progresses turn by turn and as usual, Ashish moves first.Consider the 2D plane. There is a token which is initially at (0,0). In one mov原创 2020-11-22 01:01:35 · 224 阅读 · 0 评论 -
CF1452 D. Radio Towers(斐波那契数列+概率)
链接 https://codeforces.com/contest/1452/problem/DThere are n+2 towns located on a coordinate line, numbered from 0 to n+1. The i-th town is located at the point i.You build a radio tower in each of the towns 1,2,…,n with probability 12 (these events are i原创 2020-11-20 08:56:09 · 1306 阅读 · 0 评论 -
CF1452 C. Two Brackets
链接 https://codeforces.com/contest/1452/problem/CYou are given a string s, consisting of brackets of two types: ‘(’, ‘)’, ‘[’ and ‘]’.A string is called a regular bracket sequence (RBS) if it’s of one of the following types:empty string;‘(’ + RBS + ‘)’;原创 2020-11-20 08:40:00 · 287 阅读 · 0 评论 -
CF1452 B. Toy Blocks (思维)
链接:https://codeforces.com/contest/1452/problem/BYou are asked to watch your nephew who likes to play with toy blocks in a strange way.He has n boxes and the i-th box has ai blocks. His game consists of two steps:he chooses an arbitrary box i;he tries t原创 2020-11-20 08:31:35 · 895 阅读 · 0 评论 -
CF1452 A. Robot Program
链接:https://codeforces.com/contest/1452/problem/AThere is an infinite 2-dimensional grid. The robot stands in cell (0,0) and wants to reach cell (x,y). Here is a list of possible commands the robot can execute:move north from cell (i,j) to (i,j+1);move e原创 2020-11-20 08:21:23 · 304 阅读 · 0 评论 -
CF 1440 C2. Binary Table (Hard Version)
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.You are given a binary table of size n×m. This原创 2020-11-18 13:07:51 · 457 阅读 · 2 评论 -
Codeforces 684 Div. 2 A. Buy the String B. Sum of Medians C2. Binary Table (Hard Version)
A. Buy the Stringhttps://codeforces.com/contest/1440/problem/AYou are given four integers n, c0, c1 and h and a binary string s of length n.A binary string is a string consisting of characters 0 and 1.You can change any character of the string s (the s原创 2020-11-18 01:19:54 · 522 阅读 · 0 评论 -
CF 1447 C. Knapsack (贪心)
You have a knapsack with the capacity of W. There are also n items, the i-th one has weight wi.You want to put some of these items into the knapsack in such a way that their total weight C is at least half of its size, but (obviously) does not exceed it.原创 2020-11-17 09:50:31 · 341 阅读 · 0 评论 -
CF 1438 D. Powerful Ksenia
Ksenia has an array a consisting of n positive integers a1,a2,…,an.In one operation she can do the following:choose three distinct indices i, j, k, and thenchange all of ai,aj,ak to ai⊕aj⊕ak simultaneously, where ⊕ denotes the bitwise XOR operation.She原创 2020-11-14 17:03:03 · 170 阅读 · 0 评论 -
CF1285 C. Fadi and LCM
Today, Osama gave Fadi an integer X, and Fadi was wondering about the minimum possible value of max(a,b) such that LCM(a,b) equals X. Both a and b should be positive integers.LCM(a,b) is the smallest positive integer that is divisible by both a and b. For原创 2020-11-14 16:53:44 · 128 阅读 · 0 评论 -
CF1285 D. Dr. Evil Underscores
Today, as a friendship gift, Bakry gave Badawy n integers a1,a2,…,an and challenged him to choose an integer X such that the value max1≤i≤n(ai⊕X) is minimum possible, where ⊕ denotes the bitwise XOR operation.As always, Badawy is too lazy, so you decided原创 2020-11-14 16:49:46 · 95 阅读 · 0 评论 -
CF1438 C. Engineer Artem
Artem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value ai,j written in it.If two adjacent cells contain the same value, the robot wil原创 2020-11-14 10:59:54 · 221 阅读 · 1 评论 -
CodeForces 1284 C. New Year and Permutation
Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3原创 2020-11-12 20:38:48 · 82 阅读 · 0 评论 -
CodeForces 1284 B. New Year and Ascent Sequence
A sequence a=[a1,a2,…,al] of length l has an ascent if there exists a pair of indices (i,j) such that 1≤i<j≤l and ai<aj. For example, the sequence [0,2,0,2,0] has an ascent because of the pair (1,4), but the sequence [4,3,3,3,1] doesn’t have an ascen原创 2020-11-12 20:28:52 · 132 阅读 · 0 评论 -
Codeforces 1283 E. New Year Parties
Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year…n friends live in a city which can be represented as a number line. The i-th friend lives in a house with an integer coordinate xi. The i-th friend c原创 2020-11-10 19:03:50 · 208 阅读 · 1 评论 -
Codeforces 1283 D. Christmas Trees
There are n Christmas trees on an infinite number line. The i-th tree grows at the position xi. All xi are guaranteed to be distinct.Each integer point can be either occupied by the Christmas tree, by the human or not occupied at all. Non-integer points c原创 2020-11-10 18:56:08 · 155 阅读 · 0 评论 -
Codeforces 1283 C. Friends and Gifts
There are n friends who want to give gifts for the New Year to each other. Each friend should give exactly one gift and receive exactly one gift. The friend cannot give the gift to himself.For each friend the value fi is known: it is either fi=0 if the i-原创 2020-11-10 18:42:41 · 168 阅读 · 0 评论 -
Codeforces 1280 B. Beingawesomeism
time limit per test2 secondsmemory limit per test256 megabytesinput:standard inputoutput:standard outputYou are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r×c grid.原创 2020-11-05 16:48:49 · 157 阅读 · 0 评论 -
Codeforces 1280 A. Cut and Paste
time limit per test2 secondsmemory limit per test256 megabytesinput:standard inputoutput:standard outputWe start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character o原创 2020-11-05 16:36:42 · 129 阅读 · 0 评论 -
CF1279 A到E
A. New Year GarlandPolycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called “Bu原创 2020-11-03 22:47:31 · 187 阅读 · 0 评论 -
CF 1443 D. Extreme Subtraction
You are given an array a of n positive integers.You can use the following operation as many times as you like: select any integer 1≤k≤n and do one of two things:decrement by one k of the first elements of the array.decrement by one k of the last element原创 2020-11-03 11:21:08 · 579 阅读 · 0 评论 -
codeforces 676 A到D题题解 A - XORwice/B - Putting Bricks in the Wall/C - Palindromifier/D - Hexagons
A - XORwiceIn order to celebrate Twice’s 5th anniversary, Tzuyu and Sana decided to play a game.Tzuyu gave Sana two integers a and b and a really important quest.In order to complete the quest, Sana has to output the smallest possible value of (a⊕x) + (原创 2020-10-29 19:10:20 · 817 阅读 · 0 评论 -
codeforces 1417 D - Make Them Equal
题目You are given an array a consisting of n positive integers, numbered from 1 to n. You can perform the following operation no more than 3n times:choose three integers i, j and x (1≤i,j≤n; 0≤x≤109);assign ai:=ai−x⋅i, aj:=aj+x⋅i.After each operation, al原创 2020-10-27 18:29:50 · 252 阅读 · 0 评论 -
Codeforces Round #678 (Div. 2) C. Binary Search
Andrey thinks he is truly a successful developer, but in reality he didn’t know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number x in an array. For原创 2020-10-25 19:21:56 · 311 阅读 · 1 评论 -
CF D. Bishwock
第二次写博客…D. Bishwocktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBishwock is a chess figure that consists of three squares resembling an “L-...原创 2020-01-20 23:49:09 · 134 阅读 · 0 评论