
小朋友学Codeforces
海天一树
信息学奥赛研究。
展开
-
小朋友学Codeforces(1):Round 453 DIV 2, A
902A: Visiting a Friend题目 http://codeforces.com/contest/902/problem/A代码#include <bits/stdc++.h>using namespace std;int main(){ int n, m; cin >> n >> m; int r...原创 2018-02-19 09:23:32 · 251 阅读 · 0 评论 -
Codeforces Round 472-2B题解报告
There is a rectangular grid of n rows of m initially-white cells each.Arkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows Ri and ...原创 2018-03-27 17:46:28 · 322 阅读 · 0 评论 -
Codeforces Round 473-2B题解报告
题目http://codeforces.com/contest/959/problem/B分析思路: 每一个单词对应着在原句子中的索引号,每个索引号对应着组号,每个组号对应着cost值。用第一个例子来分析: group index cost 1 1 100 2 3 1 3 2 min(1, 10) = 1...原创 2018-04-04 16:38:44 · 206 阅读 · 0 评论 -
Codeforces 967 C 题解报告
一、题目http://codeforces.com/contest/967/problem/C二、思路(一)如果是同一楼层,则直接走过去,不用爬楼梯也不用乘电梯。 (二)如果是不同楼层,分别计算爬楼梯和乘电梯所用的时间,取最小值。 (1)在计算爬楼梯所用时间时,若起始房间旁边只有一个楼梯,计算从起始房间经过该楼梯到达终点房间所需的时间。 若起始房间旁边有两个或更多的楼梯,要分...原创 2018-04-30 14:25:21 · 481 阅读 · 0 评论 -
Codeforces 976C 题解报告
一、题目http://codeforces.com/contest/976/problem/C二、思路对数据进行排序: (1)按左边的数从小到大排; (2)若左边的数相等,则按右边的数从大到小排。排序之后,若一个数的右边的数小于等于上一个数的右边的数,则这两个数必然符合题意。 比如2 132 121 11排序之后,变为1 112 132 12因...原创 2018-05-03 09:22:48 · 294 阅读 · 0 评论 -
Codeforces 980B 题解报告
一、题目http://codeforces.com/contest/980/problem/B(一)本题考察对称性 n = 5, k = 4时,以下两种方案符合题意..... .##...##............ .#.#..#.#......以下一种方案不符合题。因为这种方案,从(1,1)到(5,5)有2条最短距离,从(4,1)到(1,5)有4条最短...原创 2018-05-10 15:06:28 · 356 阅读 · 0 评论 -
Codeforces 976E 题解报告
一、题目http://codeforces.com/contest/976/problem/E二、分析(1)当把所有的倍数2 ^ a都加到同一health上,health增加的最多 (2)先计算每一个creature的hp - dmg,按该值对所有的creature排序 再求和,i三、程序#include <bits/stdc++.h>using na...原创 2018-05-04 19:05:20 · 679 阅读 · 0 评论 -
Codeforces 964B题解报告
一、题目http://codeforces.com/contest/964/problem/B大意:有n封信,每封信在ti到达,到达时价值是A,之后每秒价值减去B。如果在T(T >= ti)时刻读这封信,那么你将获得的价值是A − B ∗ (T − ti)。每秒你会获得一个价值,这个价值是C ∗ k,k表示当前未读的信件数量。每秒钟你能读无限封信,也能不读信,但是所有信必须在T秒...原创 2018-04-28 00:48:56 · 275 阅读 · 0 评论 -
Codeforces 965B 题解报告
一、题目http://codeforces.com/contest/965/problem/B二、分析当k = 1时,取第一个’.’的坐标即可 当k > 1时,需要求出每一个点在上下左右四个方向所能到达的最远处,记为up, down, left, right,再取上下方向和左右方向的和的最大值,即 max(0, up + down - k) + max(0, left +...原创 2018-04-28 19:07:58 · 364 阅读 · 0 评论 -
Codeforces 977D 题解报告
一、题目http://codeforces.com/contest/977/problem/D二、分析依题意,可以考虑一个数是3的多少次幂,可以有余数。 比如18是3的2次幂,余数为2; 9是3的2次幂,余数为0; 2是3的0次幂,余数为2。首先要把幂从高到低的顺序排列,比如9(3的2次幂)必然排在3(3的1次幂)的前面。 对于同一次幂,要按从小到大的顺序排序,这样后面...原创 2018-05-08 15:20:02 · 448 阅读 · 0 评论 -
Codeforces Round 471-2B题解报告
Let’s call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For exampl...原创 2018-03-26 16:40:33 · 476 阅读 · 0 评论 -
Codeforces Round #463 C.Permutation Cycle
一、题目http://codeforces.com/contest/932/problem/C二、分析(一)何谓Permutation Cycle以例1中的6 5 8 3 4 1 9 2 7 第一个数是6,以6为位置,则第六个数是1,以1为位置,第一个数是6,以6为位置,第六个数是1……,这样6和1就构成了一个圈子。f(1) = 6, f(6) = 1,最短的周期是2...原创 2018-02-20 17:29:23 · 350 阅读 · 0 评论 -
Codeforces Round #458 Div.2 C. Travelling Salesman and Special Numbers
一、题目http://codeforces.com/contest/914/problem/C二、分析(一)reduce规则例1:13–>1,需要三步: 十进制 二进制 1的个数 13 1101 3 3 11 2 2 10 1例2:1023–>1,需要3步 十进制...原创 2018-02-20 17:28:53 · 793 阅读 · 0 评论 -
小朋友学Codeforces(2):Round 454 DIV 2, A
题目907A. Masha and Bears题意人的体积为VV,车的大小为sizesize,人能钻进车的条件是V≤sizeV≤size,人对车满意的条件是2V≥size2V≥size. 现知道 熊爸爸能钻进最大的车并且满意 熊妈妈能钻进中等的车并且满意 熊宝宝能钻进最小的车并且满意 Masha能钻进最小的车并且只对它满意 给定四人的体积(保证V1>V2>V...原创 2018-02-19 09:24:28 · 227 阅读 · 0 评论 -
小朋友学Codeforces(3):Round 453 DIV 2, B
题目http://codeforces.com/contest/902/problem/B题意分析以第一个Example为例 第一行的数,表示结点数目为6 第二行的五个数,表示节点之间的关系 父节点 1 2 2 1 5 子节点 2 3 4 5 6用图来表示第3行的数,表示最终要涂成的每个节点的颜色...原创 2018-02-19 09:25:20 · 235 阅读 · 0 评论 -
小朋友学Codeforces(4):Round 453 DIV 2, C
题目http://codeforces.com/contest/902/problem/C分析只要满足两个条件,即存在同构树: ①该节点上一层的节点数大于1, ②该节点所在层节点个数大于1。以例2中的{1,2,2}为例:只要将最后一个节点(即节点5),放到上一层的倒数第二个节点(即结点2)下,就形成了两棵同构树。代码#include<bits/...原创 2018-02-19 09:25:48 · 263 阅读 · 0 评论 -
小朋友学Codeforces(5):Round 453 DIV 2, 902D
一、题目http://codeforces.com/contest/902/problem/D二、思路(一)最大公约数的辗转相除法对于两个整数a、b,求最大公约数gcd(a,b)的辗转相除法的算法如下// 辗转相除法 + 递归 int gcd(int num1, int num2) { if(0 == num2) { retur...原创 2018-02-19 09:26:17 · 287 阅读 · 0 评论 -
Codeforces Round #455 Div.2 909A
Problemhttp://codeforces.com/contest/909/problem/AAnalysisAccording to the problem statements, you need to consider all the characters in the first name, and only the first character in the la...原创 2018-02-19 09:26:45 · 289 阅读 · 0 评论 -
Codeforces Good Bye 2017 Div.2 908A,B
A. New Year and Counting CardsProblem Statementhttp://codeforces.com/contest/908/problem/AAnalysisFor letter, only vowel need to know the digit in the other side.For digit, only odd numb...原创 2018-02-20 17:25:48 · 355 阅读 · 0 评论 -
Codeforces查看被Hack的测试数据
需求在Codeforces上如果自己的算法通过了系统测试,但是被人hack了,想查看hack所用的数据。步骤一、点击自己的Submissions二、找到被Hack的题 三、用鼠标滚轮(注意不是左键)单击最左侧的题号“33733237”四、在新打开的页面中,点击“View Test”,即可看到测试数据 更多内容请关注微信公众号 ...原创 2018-02-20 17:26:17 · 7193 阅读 · 0 评论 -
Educational Codeforces Round 35 Div.2 A. Nearest Minimums
Problemhttp://codeforces.com/contest/911/problem/AC++ Code#include <iostream>#include <vector>using namespace std;int main(){ int m = 1000000000; int a; vector &...原创 2018-02-20 17:26:49 · 249 阅读 · 0 评论 -
Codeforces Round #456 Div.2 A. Tricky Alchemy
Problemhttp://codeforces.com/contest/912/problem/AAnalysisOne needs 2·x + y yellow and 3·z + y blue crystals. The answer therefore is max(0, 2·x + y - A) + max(0, 3·z + y - B).CodeC++...原创 2018-02-20 17:27:50 · 274 阅读 · 0 评论 -
Codeforces Round #456 Div.2 B. New Year's Eve
Problemcodeforces.com/contest/912/problem/BAnalysisYou can choose k or less than k integers from 1~n, calculate maximum xor result (1) k = 1, You can only choose one integer, so you choose n ...原创 2018-02-20 17:28:24 · 279 阅读 · 0 评论 -
Codeforces积分系统介绍
一、艾洛积分系统(Elo Ranking System)请参考 https://blog.youkuaiyun.com/haishu_zheng/article/details/80480284二、Codeforces积分系统类似于艾洛积分系统,但是具体算法没公布。 详情请参考 http://codeforces.com/blog/entry/102三、Codeforces积分与等级...原创 2018-05-28 11:59:21 · 16875 阅读 · 1 评论