Codeforces 877 C. Slava and tanks】的更多相关文章

http://codeforces.com/problemset/problem/877/C   C. Slava and tanks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Slava plays his favorite game "Peace Lightning". Now he is flying a…
C. Slava and tanks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map. Formally, map is…
codeforces 414D Mashmokh and Water Tanks 题意 题解 \(a_i\):第 \(i\) 层的结点个数. \(b_i\):第 \(i\) 层初始有水的结点个数. 如果不允许关闭水塔,最后的答案就是 \(max\{a_i\}\). 现在允许关闭部分水塔,我们可以把一些连续层数的水汇聚到同一层.假设我们汇聚 \([l, r]\) 范围的水,总花费是 \(\Sigma_{i=l}^r\{b_i*(r-i)\}\). 双指针实现即可. 代码 #include<bits…
题目链接:http://codeforces.com/problemset 题目大意:有n个格子,某些格子里可能有一个或多个坦克,但不知道具体位置,每个坦克被轰炸一次就会移动到相邻的格子里(第1个格子只能往第2个格子移动,第n个格子只能往第n-1个格子移动),被轰炸两次就会报废,问最少需要轰炸几次才能保证所有坦克全部报废,请输出轰炸的位置. 解题思路:其实就是先把1~n所有的偶数输出,再输出所有的奇数,再输出所有的偶数.因为通过题意可以知道我们需要让坦克出现在任意格子中都要被轰炸两次,才能保证摧…
[链接] 我是链接,点我呀:) [题意] 有n个位置,每个位置都可能有不定数量的tank; 你每次可以选择一个位置投掷炸弹. 并且,这个位置上的所有tank都会受到你的攻击. 并且失去一点体力. 然后它们可能会往左走一格,或者往右走一格. 每个tank的体力都为2. 问你打掉所有的tank最坏情况要多少次轰炸操作.然后输出所有的轰炸位置. [题解] 在2,4,6...轰炸 然后在1,3,5...轰炸 最后在2,4,6轰炸. 可以保证每个tank都被炸死. [代码] #include <bits/…
http://codeforces.com/contest/877/problem/D   D. Olya and Energy Drinks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Olya loves energy drinks. She loves them so much that her room is fu…
题目链接:http://codeforces.com/contest/877/problem/E 题解:显然一看就感觉要么树链剖分要么线段树+dfs序,题目要求的操作显然用线段树+dfs序就可以实现.然后就敲一下线段树+dfs序就行挺简单的只要dfs一遍记录当前节点的下表然后再加一个leng数组来存子树最多到达几然后更新或者求值的时候只要查询(pos[x],leng[x])即可. #include <iostream> #include <cstring> #include <…
题目出处:http://codeforces.com/problemset/problem/877/C 题目大意:按照游戏规则,求最小炸弹使用次数 #include<iostream> using namespace std; //本题应该是默认只能增序轰炸 int main(){ int n; cin>>n; cout<<n+n/<<endl; ;i<=n;i+=)cout<<i<<" "; ;i<=…
http://codeforces.com/problemset/problem/175/D (题目链接) 题意 A,B两人玩坦克大战,坦克有生命值,射击间隔,伤害范围,未命中的概率.问A赢的概率是多少. Solution 直接做并不好做,注意到精度要求只有$10^{-4}$,也就是说当射击次数达到一定上限之后,满足了精度要求我们就可以不做了.我们考虑按照时间dp.怎么设计状态呢,如果$f[i][j]$表示A还剩$i$点生命值,B还剩$j$点生命值,这样复杂度太高了,我们考虑将A和B剩余生命分开…
A. Alex and broken contest 题意 判断一个字符串内出现五个给定的子串多少次. Code #include <bits/stdc++.h> char s[110]; using namespace std; typedef long long LL; char* rec[5] = {"Danil", "Olya", "Slava", "Ann", "Nikita"}; i…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
C. Slava and tanks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map. Formally, map is…
B. Plane of Tanks: Pro Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/175/problem/B Description Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several…
E. Danil and a Part-time Job 题目链接:http://codeforces.com/contest/877/problem/E time limit per test2 seconds memory limit per test256 megabytes Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he i…
题目链接:http://codeforces.com/contest/877/problem/D D. Olya and Energy Drinks time limit per test2 seconds memory limit per test256 megabytes Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks. Formal…
题目链接:http://codeforces.com/contest/877/problem/B Nikita and string time limit per test2 seconds memory limit per test256 megabytes Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of t…
题目链接 题意 有 \(n\) 个容积无限的水缸,初始时水量为\(a_1,a_2,...,a_n\),有一把容积为\(k\)的勺子,可以从一个水缸中舀水倒入另一个水缸中.问能否给出操作序列,使得最终某一个水缸中水的容量为\(V\). 思路 参考 - 粉兔. 结论 首先,如果\(\sum_{i=1}^{n}a_i\lt V\),显然不可行. 否则,一旦\(\exists p_1,p_2,...,p_t,s.t.(\sum_{i=1}^{t}a_{p_i})\%k==V\%k\),则我们说,这件事是…
B. Gena's Code 题目连接: http://www.codeforces.com/contest/614/problem/B Description It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: give…
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. Water The Garden 题意:给你一个长度为\(n\)的池子,告诉你哪些地方一开始有水, 每秒可以向左和向右增加一格的水, 问什么时候全部充满水.(\(n \le 200\)) 题解:按题意模拟.每次进来一个水龙头,就更新所有点的答案 (取\(min\)).最 后把所有点取个\(max\)就…
Solved   CodeForces 920A Water The Garden   Solved   CodeForces 920B Tea Queue   Solved   CodeForces 920C Swap Adjacent Elements       CodeForces 920D Tanks       CodeForces 920E Connected Components?       CodeForces 920F SUM and REPLACE       CodeF…
C. Bus time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches…
Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map. Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Sla…
http://codeforces.com/contest/877/problem/E 真的菜的不行,自己敲一个模板,到处都是问题.哎 #include <bits/stdc++.h> using namespace std; ; #define lson (q<<1) #define rson ((q<<1)|1) struct node { int l,r,mid; int v,lazy; }tree[maxn*]; int L[maxn],R[maxn],inde…
[题目链接] https://codeforces.com/contest/877/problem/E [算法] 首先求出这棵树的DFS序 一棵子树的DFS序为连续的一段 , 根据这个性质 , 用线段树维护区间中1的个数即可 时间复杂度 : O(NlogN) [代码] #include<bits/stdc++.h> using namespace std; ; typedef long long ll; typedef long double ld; struct edge { int to…
Petya and Pipes Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 362E64-bit integer IO format: %I64d      Java class name: (Any)   A little boy Petya dreams of growing up and becoming the Head Berland…
上一次我们拿学校的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…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…