• Codeforces Round #300 解题报告


      呜呜周日的时候手感一直很好 代码一般都是一遍过编译一遍过样例

      做CF的时候前三题也都是一遍过Pretest没想着去检查...

      期间姐姐提醒说有Announcement也自信不去看

      呜呜然后就FST了

      呜呜然后rating-55(果然呜呜

      TAT


    A. Cutting Banner
     

    A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains someone else's word. The word on the banner consists only of upper-case English letters.

    There is very little time to correct the mistake. All that we can manage to do is to cut out some substring from the banner, i.e. several consecutive letters. After that all the resulting parts of the banner will be glued into a single piece (if the beginning or the end of the original banner was cut out, only one part remains); it is not allowed change the relative order of parts of the banner (i.e. after a substring is cut, several first and last letters are left, it is allowed only to glue the last letters to the right of the first letters). Thus, for example, for example, you can cut a substring out from string 'TEMPLATE' and get string 'TEMPLE' (if you cut out string AT), 'PLATE' (if you cut out TEM), 'T' (if you cut out EMPLATE), etc.

    Help the organizers of the round determine whether it is possible to cut out of the banner some substring in such a way that the remaining parts formed word CODEFORCES.

      很良心的A题...但是发现很多神犇都是写的枚举...表示不理解为何要枚举

      我的做法是直接从第一位开始和CODEFORCES匹配,从最后一位开始再从尾起和CODEFORCES匹配

      然后看匹配的位数之和如果>=CODEFORCES的位数就可以了


      

    B. Quasi Binary
     

    A number is called quasibinary if its decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011 — are quasibinary and numbers 2, 12, 900 are not.

    You are given a positive integer n. Represent it as a sum of minimum number of quasibinary numbers.

      

      这道题刚开始无脑贪心..从大的开始减,但是后来写到一半猛然发现是错的...

      例如31,如果无脑贪心的话,两个11和9个1...然而显然1个11和2个10才是答案

      然后突然发现只有0和1的数不是很少的吗...在n的范围内只有64个

      然后无脑背包就好了


    C. Tourist's Notes
     

    A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. for all i's from 1 to n - 1 the inequality |hi - hi + 1| ≤ 1 holds.

    At the end of the route the tourist rafted down a mountain river and some notes in the journal were washed away. Moreover, the numbers in the notes could have been distorted. Now the tourist wonders what could be the maximum height during his hike. Help him restore the maximum possible value of the maximum height throughout the hike or determine that the notes were so much distorted that they do not represent any possible height values that meet limits |hi - hi + 1| ≤ 1.

      这个是初一的时候普及模拟赛做过的一道一模一样的题啊..结果当时A了现在FST了..

      对于两个相邻的标记点i,j,我们设它们中间到达的最高点为k

      列出不等式a[k].y-a[i].y+a[k].y-a[j].y<=a[j].x-a[i].x

      a[k].y<=(a[j].x-a[i].x+a[i].y+a[j].y)/2

      显然当abs(a[j].y-a[i].y)>=a[j].x-a[i].x的时候无解

      然后其他情况把不等式右边取整就好了

      然后注意细节,放上Rank1爷的message镇


    D. Weird Chess
     

    Igor has been into chess for a long time and now he is sick of the game by the ordinary rules. He is going to think of new rules of the game and become world famous.

    Igor's chessboard is a square of size n × n cells. Igor decided that simple rules guarantee success, that's why his game will have only one type of pieces. Besides, all pieces in his game are of the same color. The possible moves of a piece are described by a set of shift vectors. The next passage contains a formal description of available moves.

    Let the rows of the board be numbered from top to bottom and the columns be numbered from left to right from 1 to n. Let's assign to each square a pair of integers (x, y) — the number of the corresponding column and row. Each of the possible moves of the piece is defined by a pair of integers (dx, dy); using this move, the piece moves from the field (x, y) to the field (x + dx, y + dy). You can perform the move if the cell (x + dx, y + dy) is within the boundaries of the board and doesn't contain another piece. Pieces that stand on the cells other than (x, y) and (x + dx, y + dy) are not important when considering the possibility of making the given move (for example, like when a knight moves in usual chess).

    Igor offers you to find out what moves his chess piece can make. He placed several pieces on the board and for each unoccupied square he told you whether it is attacked by any present piece (i.e. whether some of the pieces on the field can move to that cell). Restore a possible set of shift vectors of the piece, or else determine that Igor has made a mistake and such situation is impossible for any set of shift vectors.

      题目描述略晦涩...连看样例大法都不能挽救...

      然后后面看着看着突然懂了...输出的原来是对于一个圈点的攻击方式...(后来怎么看怎么明显

      然后就暴力枚举每一种攻击方式就好了

      要保证每一个点这个攻击方式攻击到的位置都被攻击到了

      这里有一个细节,就是被攻击到了并不代表一定是x

      还有可能是圈...其实这个题目描述里也有刻意提到...(唉

      然后因为这个WA了一发,其他的就是简单的大暴力


    E. Demiurges Play Again
     

    Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.

    There is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to children. In the leaves of the tree integers from 1 to m are placed in such a way that each number appears exactly in one leaf.

    Initially, the root of the tree contains a piece. Two players move this piece in turns, during a move a player moves the piece from its current nodes to one of its children; if the player can not make a move, the game ends immediately. The result of the game is the number placed in the leaf where a piece has completed its movement. The player who makes the first move tries to maximize the result of the game and the second player, on the contrary, tries to minimize the result. We can assume that both players move optimally well.

    Demiurges are omnipotent, so before the game they can arbitrarily rearrange the numbers placed in the leaves. Shambambukli wants to rearrange numbers so that the result of the game when both players play optimally well is as large as possible, and Mazukta wants the result to be as small as possible. What will be the outcome of the game, if the numbers are rearranged by Shambambukli, and what will it be if the numbers are rearranged by Mazukta? Of course, the Demiurges choose the best possible option of arranging numbers.

      这道题题意很明显..然后发现怎么不仅有两个玩家还有两个幕后操纵者...

      情况好复杂呀..弃疗...

      然后发现其实不管怎样,每个人面临的情况只有两种:顺境或逆境

      顺境也就是说幕后操纵的人和自己都想让最后结果最大化(最小化),逆境则相反

      先假设幕后操纵者支持最大化值好了

      我们考虑每个节点i最终取到的是其子树中第a[i]大的数(注意这里的第a[i]大不是第a[i]小的意思)

      如果当前节点面临顺境,那么它只要从子树中a[i]取一个最小值就好了

      因为幕后操纵者会顺着他的考虑将最大的值全放到这个子树中,这样就能让值最大化

      而如果面临逆境的话,它希望取出的数最小

      因为是幕后操纵者设计好局面在先,所以我们可以想象现在这个玩家眼前是一些已经带入具体数值的数

      他肯定会选其中最大的一个

      然而幕后操纵者希望这些所有的数里面最大的最小,那显然就是所有a[i]的加和

      然后惊奇地发言幕后操纵者支持最小化的时候,只要将第a[i]大自动带入第a[i]小,整个流程是完全一样的

      (maya刚刚淋漓说了一句惊奇地发现然后Jry也说了一句惊奇地发现...


        

    F. A Heap of Heaps
     

    Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment.

    The teacher gave Andrew an array of n numbers a1, ..., an. After that he asked Andrew for each k from 1 to n - 1 to build a k-ary heap on the array and count the number of elements for which the property of the minimum-rooted heap is violated, i.e. the value of an element is less than the value of its parent.

    Andrew looked up on the Wikipedia that a k-ary heap is a rooted tree with vertices in elements of the array. If the elements of the array are indexed from 1 to n, then the children of element v are elements with indices k(v - 1) + 2, ..., kv + 1 (if some of these elements lie outside the borders of the array, the corresponding children are absent). In any k-ary heap every element except for the first one has exactly one parent; for the element 1 the parent is absent (this element is the root of the heap). Denote p(v) as the number of the parent of the element with the number v. Let's say that for a non-root element v the property of the heap is violated if av < ap(v).

    Help Andrew cope with the task!

      比赛最后的弃疗期间yy了一个将k分段然后树状数组统计的做法,其中分段用二分实现

      最后TLE了...最后发现和标算只是相差了树状数组和二分的时间复杂度

      究竟是该开心还是遗憾好呢...

      像完全k叉树这样特殊的数据结构...早该想到父亲与儿子的标号肯定是可以O(1)计算的..写啥二分呢

      然后树状数组也没必要,树状数组只是为在线询问提供简单的方法

      但是这个只需要计算一次所以最后统计前缀和就好了

      然后那些计算自己画画就出来了..


      

      你问我G和H怎么不写题解

      像这种只有杜教才会做的题有必要去看?

      这场CF打得真是感动..虽然没有像Jry那样伤心 但也是比较难过

      果然是连着打BC和CF,RP只能光顾一边对吗...

      CF的题还是很好玩...代码也很短...这次手速太慢了

      也是第一场用Ideone敲代码的CF,感觉除了最后要复制到本地之外也没啥不方便的

      下次翻盘吧 虽然感觉再无这种全体赛的涨Rating好机会了

      

      28/.Apr.

  • 相关阅读:
    redhat 6.4重新安装python和yum
    【机器学习】置信区间上界算法UCB(Upper Confidence Bound)
    MAC终端zsh配置
    [Android] 重新打包(替换)签名APK
    UNI-APP常用方法
    一个请求的生命周期
    jquery追加元素的几种方法?(包括append()、prepend()、after()、before()、insertAfter()、insertBefore())
    怎样查外键建在哪个表上
    Redis实现分布式锁
    sql语句中对单个字段去重,distinct和group by性能分析
  • 原文地址:https://www.cnblogs.com/mjy0724/p/4463816.html
Copyright © 2020-2023  润新知