感觉这次的题目顺序很不合理啊...


A. Combination Lock
 

Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.

The combination lock is represented by n rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn some disks so that the combination of digits on the disks forms a secret combination. In one move, he can rotate one disk one digit forwards or backwards. In particular, in one move he can go from digit 0 to digit 9 and vice versa. What minimum number of actions does he need for that?

  直接模拟就好了...每一位上两个数的环上距离


B. School Marks
 

Little Vova studies programming in an elite school. Vova and his classmates are supposed to write n progress tests, for each test they will get a mark from 1 to p. Vova is very smart and he can write every test for any mark, but he doesn't want to stand out from the crowd too much. If the sum of his marks for all tests exceeds value x, then his classmates notice how smart he is and start distracting him asking to let them copy his homework. And if the median of his marks will be lower than y points (the definition of a median is given in the notes), then his mom will decide that he gets too many bad marks and forbid him to play computer games.

Vova has already wrote k tests and got marks a1, ..., ak. He doesn't want to get into the first or the second situation described above and now he needs to determine which marks he needs to get for the remaining tests. Help him do that.

  这道题的简单思路就是在中位数满足条件的情况下

  让整个序列都尽量小,以尽量满足第一个条件

  首先如果读入的中位数下限是x,那么显然最终序列的中位数也是x

  我们假设最终中位数不是x,而是原序列中第i小的数a[i]

  那么a[i]以左不够n/2的数用1填,a[i]以右不够n/2的数用a[i]填

  然而这个时候如果我们用x作为中位数,x的位置只会小于等于i

  先看小于的时候,左边填的1的个数更多了,右边填的x的个数更少了,显然总和会小

  等于的时候,左边填的1不变,右边填的个数也不变,只是用x填,而x<=a[i],所以总和会更小

  因为题目保证k<n,总要填一个数,所以不论如何中位数取x总没错

  需要判断的就是左右的个数和总和,但是要注意一些细节

  当然可能是我的方法不大好所以产生了很多细节需要判断

  类似于:原序列中没有数、原序列中没有大于等于x的数... 


C. Ice Cave
 

You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.

The level of the cave where you are is a rectangular square grid of n rows and m columns. Each cell consists either from intact or from cracked ice. From each cell you can move to cells that are side-adjacent with yours (due to some limitations of the game engine you cannot make jumps on the same place, i.e. jump from a cell to itself). If you move to the cell with cracked ice, then your character falls down through it and if you move to the cell with intact ice, then the ice on this cell becomes cracked.

Let's number the rows with integers from 1 to n from top to bottom and the columns with integers from 1 to m from left to right. Let's denote a cell on the intersection of the r-th row and the c-th column as (r, c).

You are staying in the cell (r1, c1) and this cell is cracked because you've just fallen here from a higher level. You need to fall down through the cell (r2, c2) since the exit to the next level is there. Can you do this?

  这道题的样例好讨厌啊><

  绕了一大圈然后就决定用网络流做了...虽然觉得好不科学啊cf上的题居然还有那么长的代码?

  最后光荣RE 也不打算去找哪里出错了...毕竟是一道不那么难的题

  对于一个未破裂的点,我们有时需要找到一条全是未破裂格子的路绕回到这个点

  其实非常简单,只要它的四周存在一个未破裂的点,走到那里,然后再回来就可以了...

  其他情况完全没必要去考虑

  这样了之后,整道题的思路就简单了好多

  首先考虑起点和终点重合的情况,只要四周有一个未破裂的点就可以了

  然后考虑其他情况,首先我们需要起点到终点存在一条未破裂格子组成的道路

  当然如果两点相邻那就不用考虑了

  然后分情况讨论

  如果终点是破裂的话,那就直接YES

  如果未破裂,意味着要从这个点的四周再找一个未破裂的格子

  所以只要存在一条起点到终点的路径,并且终点的四周存在>=2个未破裂的格子就可以了


D. Bad Luck Island
 

The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, then one individual kills the other one: a rock kills scissors, scissors kill paper, and paper kills a rock. Your task is to determine for each species what is the probability that this species will be the only one to inhabit this island after a long enough period of time.

  看到这么简单的D的时候简直惊呆了...

  定义一个f[i,j,k]表示有i个石头j个剪刀k个布的概率

  初始情况f[r,s,p]=1,然后从前往后推比较方便

  当石头减少1个的时候,意味着一个石头和一个布见面,概率是i*k/(i*k+i*j+k*k)

  注意这里的分母不是C(i+j+k,2),因为当两个同种类的村民见面的时候不会发生任何事情可以忽略

  另外两种情况同理


E. Infinite Inversions
 

There is an infinite sequence consisting of all positive integers in the increasing order: p = {1, 2, 3, ...}. We performed n swapoperations with this sequence. A swap(a, b) is an operation of swapping the elements of the sequence on positions a and b. Your task is to find the number of inversions in the resulting sequence, i.e. the number of such index pairs (i, j), that i < j and pi > pj.

  看到这么简单的E的时候简直惊呆了...

  离散一下数据然后模拟一下然后统计一下逆序对好像就可以了...

  当然这只是一部分的答案

  还有一部分是没有在读入中出现的那些数字

  对于每一个再读入里出现的数字,只要统计那些在它原位与当前位置之前的没有出现过的数就可以了

  这个可以预处理,然后前缀和,最后统计一下就好了

  (看到一个TAG是trees,表示非常不理解...


  要加油啊....

  另外,祝

  策爷 松爷 约大爷 数国队 杜教 

  CTSC成功虐场

  2/.May

Codeforces Round #301 解题报告的更多相关文章

  1. Codeforces Round #300 解题报告

    呜呜周日的时候手感一直很好 代码一般都是一遍过编译一遍过样例 做CF的时候前三题也都是一遍过Pretest没想着去检查... 期间姐姐提醒说有Announcement也自信不去看 呜呜然后就FST了 ...

  2. Codeforces Round #513解题报告(A~E)By cellur925

    我是比赛地址 A:Phone Numbers $Description$:给你一串数字,问你能组成多少开头为8的11位电话号码. $Sol$:统计8的数量,与$n$%11作比较. #include&l ...

  3. Codeforces Round #302 解题报告

    感觉今天早上虽然没有睡醒但是效率还是挺高的... Pas和C++换着写... 544A. Set of Strings   You are given a string q. A sequence o ...

  4. DFS/BFS Codeforces Round #301 (Div. 2) C. Ice Cave

    题目传送门 /* 题意:告诉起点终点,踩一次, '.'变成'X',再踩一次,冰块破碎,问是否能使终点冰破碎 DFS:如题解所说,分三种情况:1. 如果两点重合,只要往外走一步再走回来就行了:2. 若两 ...

  5. 贪心 Codeforces Round #301 (Div. 2) B. School Marks

    题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...

  6. 贪心 Codeforces Round #301 (Div. 2) A. Combination Lock

    题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <a ...

  7. CFEducational Codeforces Round 66题解报告

    CFEducational Codeforces Round 66题解报告 感觉丧失了唯一一次能在CF上超过wqy的机会QAQ A 不管 B 不能直接累计乘法打\(tag\),要直接跳 C 考虑二分第 ...

  8. 【解题报告】Codeforces Round #301 (Div. 2) 之ABCD

    A. Combination Lock 拨密码..最少次数..密码最多有1000位. 用字符串存起来,然后每位大的减小的和小的+10减大的,再取较小值加起来就可以了... #include<st ...

  9. Codeforces Global Round 1 解题报告

    A 我的方法是: #include<bits/stdc++.h> using namespace std; #define int long long typedef long long ...

随机推荐

  1. DSP28335的XINTF操作SRAM实验

    1. 本次使用三兄弟的XDS28335开发板,研究一下XINTF操作SRAM的代码.哈弗结构,奇怪,DSP28335是哈弗结构,那么数据和程序空间应该独立的,为啥书上说采用统一的寻址方式?估计只是读写 ...

  2. [网站公告]18:07-18:20阿里云SLB故障造成网站不能正常访问

    (注:由于阿里云SLB管理控制台监控数据不准,实际故障时间是18:07-18:20.) 17:55-18:2018:07-18:20,我们使用的阿里云SLB(负载均衡)中有3台出现突发故障,造成全站无 ...

  3. Spring 整合 Shiro

    一.引入依赖 <!-- spring start --> <dependency> <groupId>org.springframework</groupId ...

  4. python 基础篇 14 程程器表达式 内置函数

    昨日内容回顾    可迭代对象:        内部含有__iter__方法的就是可迭代对象.        可迭代对象不能取值,因为内部不含有__next__方法.     可迭代对象 ---> ...

  5. const 常量与 define常量的区别

    c++中的常量可以使用const定义,也可以使用#define宏定义的方式:二者区别如下: - **区别** 1. const定义的常量有自己的数据类型,编译器可以对其进行严格的类型检查:但是defi ...

  6. ORACLE和SQL语法区别归纳

    数据类型比较类型名称 Oracle   SQLServer   比较字符数据类型  CHAR  CHAR  都是固定长度字符资料但oracle里面最大度为2kb,SQLServer里面最大长度为8kb ...

  7. scp源码浅析

    背景: 经常使用scp传文件,发现它真的很给力,好奇心由来已久! 恰好接到一个移植SSH服务到专有网络(非IP网络)的小任务,完成工作又能满足好奇心,何乐而不为! 我只从源码浅浅的分析一下,后续有更多 ...

  8. docker/qemu中是如何对设备管理的

    文件系统中包括实际的磁盘中可读可写的. 容器中看到的设备是啥子呢?--docker qemu也是一样,在qemu中添加一个设备的物理意义是啥子嘛 其实设备也没啥好新奇的,不就是一个普通的文件么,然后在 ...

  9. [剑指Offer] 38.二叉树的深度

    题目描述 输入一棵二叉树,求该树的深度.从根结点到叶结点依次经过的结点(含根.叶结点)形成树的一条路径,最长路径的长度为树的深度. [思路1]递归 /* struct TreeNode { int v ...

  10. SPOJ HIGH(生成树计数,高斯消元求行列式)

    HIGH - Highways no tags  In some countries building highways takes a lot of time... Maybe that's bec ...