CodeForces - 13E】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/13/E 题意:给定n个弹簧和每个弹簧初始的弹力a[].当球落在第i个位置.则球会被弹到i+a[i]的位置. 现在有2种操作: 1 a b:把第a个弹簧的弹力修改为b. 2 a:当球初始放入的位置为a时,需要弹几次才会弹出n.弹出前的最后一个位置是多少. 输出位置和次数. 思路:和BZOJ 2002一样. 然后记录一个最后弹出去的位置preidx.每次弹出当前块的时候记录当前的位置即可.然后最后再暴力模拟…
题目链接 nextt数组表示这个位置的下一个位置. cnt数组表示这个位置 i 到nextt[i]可以弹几次. end[i] 表示在从 i 弹出去的情况下, 最后一个位置是哪里. 然后就看代码吧. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #includ…
正解是动态树,太难了,仅仅好分块处理水之.看了看status大概慢了一倍之多..     分块算法大体就是在找一个折衷点,使得查询和改动的时间复杂度都不算太高,均为o(sqrt(n)),所以总的时间复杂度为o(m*sqrt(n)).     分块的大体思想就是将整段区间分成sqrt(n),每次改动影响所在段内的sqrt(n)个点.每次查询遍历sqrt(n)段,然后搞出一些事情.     对于此题,首先说明几个数组的含义:     cnt[i]的意义为从i点開始跳出其所在段所须要的步数.    …
Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules: There are N holes located in a single row and numbered from left to right with numbers from 1 to N. Each hole has it's…
题意 n(n≤105)个洞排成一条直线,第ii个洞有力量值ai,当一个球掉进洞ii时就会被立刻弹到i+ai,直到超出n.进行m(m≤105)次操作: ·修改第i个洞的力量值ai. ·在洞xx上放一个球,问该球几次后被哪个洞弹飞出界. 思路 分块暴力,每个块内维护两个信息(块内DP可以求出): ①从当前位置跳出块内需要跳几次num[i] ②从当前块内跳出的下一个位置jump[i] 修改: 只需要将修改元素所在块内信息更新一次即可,单次时间复杂O(√n) 查询: 由起点i不停往下一个块跳jump[i…
Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules: There are N holes located in a single row and numbered from left to right with numbers from 1 to N. Each hole has it's…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…