
CF
Tizzii
这个作者很懒,什么都没留下…
展开
-
CodeForces 1323D Present
一、内容Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for eac...原创 2020-03-09 15:54:17 · 688 阅读 · 0 评论 -
CodeForces - 1323 C Unusual Competitions
一、内容A bracketed sequence is called correct (regular) if by inserting "+" and "1" you can get a well-formed mathematical expression from it. For example, sequences "(())()", "()" and "(()(()))" are co...原创 2020-03-09 11:50:44 · 589 阅读 · 1 评论 -
CodeForces - 1323B Count Subrectangles
一、内容You are given an array a of length n and array b of length m both consisting of only integers 0 and 1. Consider a matrix c of size n×m formed by following rule: ci,j=ai⋅bj (i.e. ai multiplied by ...原创 2020-03-09 11:39:42 · 596 阅读 · 0 评论 -
CodeForces 1300 E Water Balance 单调栈+贪心
一、内容There are n water tanks in a row, i-th of them contains ai liters of water. The tanks are numbered from 1 to nfrom left to right.You can perform the following operation: choose some subsegment [l...原创 2020-02-23 12:22:52 · 423 阅读 · 0 评论 -
CodeForces - 1300 A Non-zero B Assigning to Classes C Anu Has a Function
A统计0的个数,每个0都要加上1,如果最后总和是0,那么还得在一个正数上加1。#include <cstdio>#include <cstring>using namespace std;int t, n, num;int main() { scanf("%d", &t); while (t--) { int sum = 0, cnt = ...原创 2020-02-23 11:01:46 · 434 阅读 · 0 评论 -
CodeForces 1303F Number of Components 删边并查集
一、内容You are given a matrix n×m, initially filled with zeroes. We define ai,j as the element in the i-th row and the j-th column of the matrix.Two cells of the matrix are connected if they share a sid...原创 2020-02-21 13:49:54 · 478 阅读 · 0 评论 -
CodeForces 1303 E rase Subsequences dp
一、内容You are given a string s. You can build new string p from susing the following operation no more than two times: choose any subsequence si1,si2,…,sikwhere 1≤i1<i2<⋯<ik≤|s|;erase the chos...原创 2020-02-20 17:12:08 · 465 阅读 · 0 评论 -
CodeForces - 1303 D Fill The Bag 二进制
一、内容You have a bag of size n. Also you have m boxes. The size of i-th box is ai, where each aiis an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is t...原创 2020-02-20 15:28:40 · 456 阅读 · 0 评论 -
CodeForces - 1303C Perfect Keyboard
一、内容Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where all 26lowercase Latin letters will be arrang...原创 2020-02-20 13:54:07 · 605 阅读 · 0 评论 -
CodeForces - 1303 A Erasing Zeroes B National Project
A统计2个1中间0的个数#include <cstdio>#include <cstring>using namespace std;const int N = 105;int t, n;char s[N]; int main() { scanf("%d", &t); while (t--) { scanf("%s", s + 1);...原创 2020-02-20 13:26:32 · 410 阅读 · 0 评论 -
CodeForces - 1296 F Berland Beauty dfs暴力枚举
一、内容There are n railway stations in Berland. They are connected to each other by n−1railway sections. The railway network is connected, i.e. can be represented as an undirected tree.You have a map of...原创 2020-02-19 16:31:09 · 492 阅读 · 2 评论 -
CodeForces - 1307D Cow and Fields 差值排序
一、内容Bessie is out grazing on the farm, which consists of n fields connected by m bidirectional roads. She is currently at field 1, and will return to her home at field nat the end of the day.The Cowf...原创 2020-02-19 13:04:06 · 775 阅读 · 1 评论 -
CodeForces 1307 C Cow and Message dp
一、内容Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside.The text is a string sof lowercase Latin let...原创 2020-02-19 11:27:19 · 589 阅读 · 0 评论 -
Codeforces Round #621 (Div. 1 + Div. 2) A Cow and Haybales B Cow and Friend
A#include <cstdio>#include <algorithm>using namespace std;int t, n, k, num, ans;int main() { scanf("%d", &t); while (t--) { scanf("%d%d%d", &n, &k, &ans); for (i...原创 2020-02-19 11:15:04 · 492 阅读 · 0 评论 -
CodeForces - 1296E2 String Coloring (hard version) dp
一、内容This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are differe...原创 2020-02-18 17:56:28 · 460 阅读 · 0 评论 -
CodeForces - 1296E1 String Coloring (easy version) 贪心
一、内容This is an easy version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are differ...原创 2020-02-18 15:46:30 · 466 阅读 · 0 评论 -
CodeForces - 1296D Fight with Monsters
一、内容There are n monsters standing in a row numbered from 1 to n. The i-th monster has hi health points (hp). You have your attack power equal to a hp and your opponent has his attack power equal to b...原创 2020-02-18 13:51:17 · 475 阅读 · 0 评论 -
Codeforces Round #617 (Div. 3) A Array with Odd Sum B Food Buying C Yet Another Walking Robot
A#include <cstdio>int t, n, num;int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); int odd = 0; for (int i = 1; i <= n; i++) { scanf("%d", &num); if (num ...原创 2020-02-18 13:21:06 · 409 阅读 · 0 评论 -
CodeForces 1304F2 Animal Observation (easy version) DP + 滑动窗口优化
一、内容The only difference between easy and hard versions is the constraint on kGildong loves observing animals, so he bought two cameras to take videos of wild animals in a forest. The color of one cam...原创 2020-02-16 20:49:41 · 691 阅读 · 0 评论 -
CodeForces 1304F1 Animal Observation (easy version) DP
一、内容The only difference between easy and hard versions is the constraint on kGildong loves observing animals, so he bought two cameras to take videos of wild animals in a forest. The color of one cam...原创 2020-02-16 17:03:36 · 677 阅读 · 0 评论 -
CodeForces - 1304D Shortest and Longest LIS
一、内容Gildong recently learned how to find the longest increasing subsequence (LIS) in O(nlogn) time for a sequence of length n. He wants to test himself if he can implement it correctly, but he couldn...原创 2020-02-16 13:46:48 · 603 阅读 · 0 评论 -
CodeForces 1304E 1-Trees and Queries LCA
一、内容Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?The...原创 2020-02-16 11:01:56 · 540 阅读 · 0 评论 -
Codeforces #620 (Div. 2)A Two Rabbits B - Longest Palindrome C - Air Conditioner
A#include <cstdio>#include <algorithm>#include <cstring>using namespace std;int t, a, b, x, y;int main() { scanf("%d", &t); while (t--) { scanf("%d%d%d%d", &x, &...原创 2020-02-16 10:26:01 · 421 阅读 · 0 评论 -
Codeforce 1304 C. Air Conditioner
一、内容Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he ev...原创 2020-02-15 23:18:10 · 580 阅读 · 0 评论 -
CodeForces - 1301F Super Jaber 多源BFS
一、内容Jaber is a superhero in a large country that can be described as a grid with n rows and mcolumns, where every cell in that grid contains a different city.Jaber gave every city in that country a s...原创 2020-02-15 19:54:26 · 628 阅读 · 0 评论 -
CodeForces - 1301E Nanosoft 二分+二维前缀和
一、内容Warawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building.The logo of Nanos...原创 2020-02-15 13:25:59 · 543 阅读 · 0 评论 -
CodeForces 1301D Time to Run 模拟
一、内容Bashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Basha...原创 2020-02-14 20:02:49 · 632 阅读 · 0 评论 -
Codeforces #619 (Div. 2) A Three Strings B Motarack's Birthday C Ayoub's function
A只要a[i]和b[i]其中有一个与c[i]相等,那么可以直接用c[i]替换另外一个。 若都不相等无法替换。(必须替换n次)#include <cstdio>#include <cstring>using namespace std;const int N = 105;int n;char a[N], b[N], c[N];bool ok() { in...原创 2020-02-14 13:40:03 · 480 阅读 · 0 评论 -
A. Equation CodeForces - 1269A
一、内容Let's call a positive integer composite if it has at least one divisor other than 1and itself. For example: the following numbers are composite: 1024, 4, 6, 9;the following numbers are not compo...原创 2019-12-21 21:50:59 · 649 阅读 · 0 评论 -
B.Modulo Equality CodeForces - 1269B
一、内容You are given a positive integer m and two integer sequence: a=[a1,a2,…,an] and b=[b1,b2,…,bn]. Both of these sequence have a length nPermutation is a sequence of ndifferent positive integers fro...原创 2019-12-21 21:36:30 · 671 阅读 · 0 评论 -
Jeremy Bearimy CodeForces - 1281E 贪心
一、内容题意:给定2 * k个点,问选择k对点(每个点都必须选上)进行相连,求出所有路径之和。求出路径之和的最大值和最小值。二、思路最大化路径之和: 首先我们任选2个组件记性相连,如图当我们选择左边的任意2个点相连和右边任意2个相连,如(1,3) (4, 6)。那么可以转化为左边组件和右边组件进行相连。(1,4)(3,6)或者(1,6)(3,4)那么这样相连后, 我们在保存了以前...原创 2019-12-19 11:13:14 · 708 阅读 · 0 评论 -
Cut and Paste CodeForces - 1281C
一、内容We 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 of s is denoted by siThere is one cursor. The cu...原创 2019-12-18 19:00:14 · 563 阅读 · 3 评论 -
Azamon Web Services CodeForces - 1281B
一、内容题意:问最多替换一对字符后是否能够严格小于另一个串(相等不算作严格小于)二、思路当a作为c的前缀的时候,a比c小。我们只需要对a进行排序,然后找到与b(排序后的串)第一个不相等字符处,然后将a串这个位置换成b串的这个位置的字符。由于要变成最小的串,所以我们应该从a串的末尾进行查找,这样替换的串更小。三、代码#include <cstdio>#include ...原创 2019-12-17 21:56:23 · 529 阅读 · 0 评论 -
Happy Birthday, Polycarp! CodeForces - 1277A
一、内容题意:问1-n中有多少个数是全部相同的数字组成的。如111,222,333,1,2,3,4。。。二、思路每次将n除以相同的基数 和 9进行比较。三、代码#include <cstdio>#include <algorithm>using namespace std;typedef long long ll;int t, n, ans;int ...原创 2019-12-17 18:22:10 · 476 阅读 · 0 评论 -
Make Them Odd CodeForces - 1277B
一、内容题意:将所有的偶数都变成奇数,问最少需要多少步。每次选定一个偶数,然后所有相同的数都除2.二、思路如果当前的数不是偶数,就用map记录当前偶数,如果已经访问过就不用再除2了,如果没有访问过那么就一直除2。三、代码#include <cstdio>#include <unordered_map>#include <algorithm>u...原创 2019-12-17 18:15:17 · 435 阅读 · 0 评论 -
Codeforce 1277 C. As Simple as One and Two
一、内容题意:不能出现one 或者 two 这2个字符串。问最少需要删除那些字符,并输出删除的位置。二、思路我们只需要删除one的n 或者是two的w就可以让一个字符串不出现这2个串。特殊情况:当 twone这种情况时,我们需要删除的是 o 这个字符。三、代码#include <cstdio>#include <cstring>#define min(a...原创 2019-12-17 18:03:41 · 423 阅读 · 0 评论 -
Codeforces 1277D. Let's Play the Words?
一、内容题意:给定几个01二进制字符串,问你可以翻转任意的字符串,让所有的字符串能够拼接起来,且所有的串都是惟一的(不重复)。二、思路用map记录某个串是否存在,如果存在就进行翻转,如果翻转后还存在那么不合法。0–0 1—1 这种字符串字节拼接在0—1 或者1—0的前面后面即可,所以我们统计出01,10,11,00开头结尾的字符串的个数,然后分情况讨论输出-1的情况: 当00,11存在...原创 2019-12-17 16:59:18 · 621 阅读 · 0 评论 -
Beautiful Rectangle CodeForces - 1277F
一、内容题意:凑出每行每列的元素都不相同的最大矩阵(元素最多)。二、思路由于每行不能一样,所以我们选取i行,那么最多可以选取i个相同的值。 列可以随意增加,行需要限制一下。三、代码#include <cstdio>#include <algorithm>using namespace std;const int N = 4e5 + 5;struct n...原创 2019-12-16 12:08:58 · 528 阅读 · 2 评论 -
Two Fairs CodeForces - 1277E dfs
一、内容There are n cities in Berland and some pairs of them are connected by two-way roads. It is guaranteed that you can pass from any city to any other, moving along the roads. Cities are numerated fr...原创 2019-12-15 20:18:45 · 551 阅读 · 2 评论 -
Nearest Opposite Parity CodeForces - 1272E bfs
一、内容You are given an array a consisting of n integers. In one move, you can jump from the position i to the position i−ai (if 1≤i−ai) or to the position i+ai (if i+ai≤n).For each position i from 1 to...原创 2019-12-13 17:34:54 · 27792 阅读 · 0 评论