codeforces
文章平均质量分 85
黑码
这个作者很懒,什么都没留下…
展开
-
codeforces Nastya and Scoreboard(dp)
题意:0~9每个数字由不同数量位置的火柴棍组成,一共n组数字,让你添加k根火柴棍,使n组数字可以构造的最大的数。若不能构成任何数,那么输出 -1dp[i][j] 第i个数时,还剩下j个火柴棍,dp[i][j] = 1代表这个状态是可以构成的。那么初始值 dp[n+1][0] = 1代表 n+1个数时,剩下0个火柴棍的状态是1。从后往前推可以达到的状态,最后从前往后贪心得到结果。#incl...原创 2020-04-25 10:41:10 · 200 阅读 · 0 评论 -
codeforces D Xenia and Colorful Gems
给 t给 nr,ng,nb三种宝石数量nr个宝石的价值ng个宝石的价值nb个宝石的价值每种宝石各取一个,使 (xx-yy)^2+ (xx-zz)^2 + (yy-zz)^2 最小展开,有 2(xx + yy + zz) - 2xy - 2xz - 2yz 最小 由不等式可知 xx==yy==zz最小,答案为0则推 当xyz 差值最小的时候 答案最小 所以 分别对三种...原创 2020-04-16 11:45:43 · 228 阅读 · 0 评论 -
codeforces E2. Three Blocks Palindrome (hard version)
给你一个序列,你要可以在这些序列中进行删除操作,最后这个序列形成abaabaaba回文序列,并且a,ba,ba,b中的数字要一样,问这个的序列最长的长度是多少。分析:收尾两边同时逐一增加某字符,然后和中间相同字符个数,拼接起来,找到最大值#include <bits/stdc++.h>using namespace std;#define fi first#define...原创 2020-04-15 16:30:50 · 261 阅读 · 0 评论 -
codeforces 632C Eugene and an array
给定长度为n的序列,定义序列a为“好的”,当且仅当,a的子段中不存在sum值为0。那么根据题意,若sum[a[i]]在i前面存在,那么这样的序列只能最后一次取到sum[a[i]]的下标k以后,数量为i - k。#include <bits/stdc++.h>using namespace std;#define fi first#define se second#d...转载 2020-04-09 12:41:57 · 266 阅读 · 0 评论 -
codeforces 1332C K-Complete Word
K-Complete Wordtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWord????sof length????nis called????k-complete if????sis a palindrome...原创 2020-04-01 14:32:04 · 390 阅读 · 1 评论 -
codeforces 1332D 构造
小明有一个动态规划程序是为了解决一个矩阵只能往右走或者往下走相与的最大值 是 dp[i][j] = max(dp[i-1][j] & a[i][j], dp[i][j - 1]&a[i][j]) ,然后说这个程序是错的,有真正的对的答案,给一个k 是 这个错误答案与正答的差值,让构造这个矩阵只要给一条有k的路,但是动态规划程序是不会走这条路的矩阵即可构造3*3 矩阵 ...原创 2020-04-01 14:04:03 · 237 阅读 · 0 评论 -
codeforces Anton and Fairy Tale
C. Anton and Fairy Tale time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Anton likes to listen to fairy tales, especially when Danik, Anton’原创 2017-03-16 09:29:03 · 357 阅读 · 0 评论 -
codeforces 414C 归并排序
这个大神写得很好 http://www.tuicool.com/articles/iau67j先复制一个思路:解法:2^n个数,可以联想到建立一棵二叉树的东西,比如 2,1,4,3就可以建成下面这样 [2,1,4,3] level 2原创 2017-04-02 11:27:34 · 652 阅读 · 0 评论 -
codeforces 154A (对 思维)
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represen原创 2017-04-13 23:58:26 · 391 阅读 · 0 评论 -
codeforces 154B 素筛 机器激活
By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating sev原创 2017-04-14 00:00:57 · 449 阅读 · 0 评论 -
codeforces Igor and his way to work
B. Igor and his way to work time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Woken up by the alarm clock Igor the financial analyst hurried原创 2017-04-24 12:09:39 · 937 阅读 · 2 评论 -
codeforces Volatile Kite (向量的操作模板)
B. Volatile Kite time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given a convex polygon P with n distinct vertices p1, p2, …, pn.原创 2017-04-17 13:35:38 · 514 阅读 · 0 评论 -
codeforces C. Voltage Keepsake (浮点数二分坑点控制精度可解决)
题意: 给你n个装置,每个装置每分钟耗电p ,本身储存电c。 然后你有一个充电器,(随时充,转移不耗时,想怎么换着充都行)。 问你让所有装置都能保持工作的最大时间是多少。以前模板都是用 1e-9 但是这里其实只需要到1e-5(虽然这能水过,但是这不是重点)。 右边界得到1e11以上,1e-9加上1e11 基本上就超过1e20了。会超时。所以减少精度或者限定次数都可以。他们都是迭代 150原创 2017-04-17 11:29:11 · 977 阅读 · 2 评论 -
codeforces 445B DZY Loves Chemistry 贪心 dfs 并查集
DZY loves chemistry, and he enjoys mixing chemicals.DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, in a原创 2017-08-09 23:53:40 · 471 阅读 · 0 评论 -
codeforces Plant Tree
include转载 2017-03-12 01:25:23 · 328 阅读 · 0 评论 -
codeforces Coloring Brackets
Once Petya read a problem about a bracket sequence. He gave it much thought but didn’t find a solution. Today you will face it.You are given string s. It represents a correct bracket sequence. A correc原创 2017-03-11 00:31:50 · 346 阅读 · 0 评论 -
cf 367B Sereja ans Anagrams
Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, …, an. Similarly, sequence b consists of m integers b1, b2, …, bm. As usual, Sereja studies the sequences he has原创 2017-03-11 00:27:59 · 388 阅读 · 0 评论 -
C. Mahmoud and a Message 396 div2 C dp好题
Mahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disapp原创 2017-02-08 14:52:34 · 452 阅读 · 0 评论 -
Mahmoud and a Dictionary codeforces396 div2 D
D. Mahmoud and a Dictionary time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mahmoud wants to write a new dictionary that contains n words原创 2017-02-08 18:30:22 · 468 阅读 · 0 评论 -
codeforces 392 div2 D ability to convert
D. Ability To Convert time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alexander is learning how to convert numbers from the decimal原创 2017-01-20 20:00:46 · 328 阅读 · 0 评论 -
codeforces 392 div2 unfair poll
C. Unfair Poll time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output On the Literature lesson Sergei noticed an awful injustice, it seems that so原创 2017-01-20 20:09:19 · 504 阅读 · 0 评论 -
codeforces 397div2 D Artsem and Saunders
D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Sa原创 2017-02-15 01:00:24 · 414 阅读 · 0 评论 -
codeforces 397div2 D Artsem and Saunders
D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Sa原创 2017-02-15 01:00:25 · 253 阅读 · 0 评论 -
codeforces 397div2 D Artsem and Saunders
D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Sa原创 2017-02-15 01:08:27 · 287 阅读 · 0 评论 -
codeforces 735D Taxes 哥德巴赫猜想
哥德巴赫猜想,一个偶数可以是两个质数之和,那么一个奇数x有三种情况: 1.x本身是质数 2.(x-2)是质数,那么可以拆成两个质数 3.拆成一个质数和一个偶数,即三个质数#include<bits/stdc++.h>using namespace std;bool isprime(int n) { if(n < 2)return false; for(int i = 2;原创 2017-02-15 11:17:09 · 319 阅读 · 0 评论 -
C. Timofey and a tree codeforces 395 div2 C
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it’s time for Timofey birt原创 2017-02-03 11:30:00 · 472 阅读 · 0 评论 -
codeforces Dima and Salad
You helped Dima to have a great weekend, but it’s time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong.Inna and Dima are now in one room. Inna tells Dima off for原创 2017-03-08 13:09:49 · 327 阅读 · 0 评论 -
codeforces The Meeting Place Cannot Be Changed
The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.At some points on the road the原创 2017-03-06 10:16:54 · 444 阅读 · 0 评论 -
Codeforces Andryusha and Colored Balloons
题意 给定点数和边数,使任意相连的三个点颜色不一样。 dfs:每次把所到点的每条边的点都染上,而且要与上一个点和上上个点颜色不一样即可。#include <bits/stdc++.h>using namespace std;vector<int> v[201000];int num;int n;int c[201000];void dfs(int x,int f){ int原创 2017-03-06 10:12:21 · 348 阅读 · 0 评论 -
codeforces MUH and Cube Walls (kmp)
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes原创 2017-03-19 12:18:30 · 584 阅读 · 0 评论 -
codeforces Sereja and Algorithm
Sereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let’s represent the input string of the algorithm as q = q1q2… qk. The algorithm原创 2017-03-11 00:22:18 · 300 阅读 · 0 评论 -
codefoeces 755B
题意:两个人两张表,里面可能有相同的词,每人说一个新词,不能说的就输了 没读好题被hack掉,给定两个表分别是 You’re given two lists of words familiar to PolandBall and EnemyBall. 那么其实要求的是相同的词的个数,如果相同的词有奇数个其实就是第一个读的人可以有多一个词,如果是偶数个,那么二者相同 贴代码#include原创 2017-01-17 10:42:42 · 412 阅读 · 0 评论