CF#537 C. Creative Snap /// DFS】的更多相关文章

题目大意: 给定n k A B为位置长度 复仇者个数 两种花费 在一段为1~2^n的位置中 某些位置存在一些复仇者 求消灭所有复仇者的最小花费 对一段位置可以有两种处理方式 1.若该段长度至少为2 可以将其分成长度相等的两段分开处理 2.若该段中不存在复仇者 那么一共只需花费 A 若该段中存在复仇者 那么花费为 复仇者个数*该段长度*B 将复仇者位置排序后 对范围[l,r]的一段 利用二分函数就可获得该段中复仇者的个数 对整段[1,2^n]深搜一下 复杂度不超过O((2^n)<<2) #inc…
传送门 简单的dfs+dp即可解决.根本不用动态开点 /* * Author: heyuhhh * Created Time: 2019/11/13 10:12:42 */ #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define INF 0…
题面: 传送门 题目描述: 灭霸想要摧毁复仇者联盟的基地.基地的长度为2的n次方,基地可以看成是一个长度为2的n次方的数组.基地的每一个位置可以由很多个超级英雄,但是一个超级英雄只能站一个位置.灭霸想用最小的力量摧毁复仇者联盟的基地.从破坏一整个基地开始,每一步他可以执行其中一项操作: 1.如果当前基地长度大于等于2,那么灭霸可以把基地分开成两半. 2.烧掉当前基地.如果当前基地没有任何超级英雄,则需要A的力量.否则,灭霸需要B*num*l的力量.其中num是当前基地的超级英雄数量,l是当前基地…
Creative Snap C. Creative Snap time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base. Let we…
https://codeforces.com/contest/1111/problem/C 横坐标1..2^n对应着2^n个复仇者的基地,上面有k个复仇者(位置依次给出).你是灭霸你要用以下方法消灭这k个复仇者:一开始你获取整个区间[1..2^n]假设你当前获取的区间为[l,r]mid = (l+r)/2那么你每次有两种选择1.将整个区间全都毁掉,如果这个区间里没有复仇者,那么花费为A,否则花费为B复仇者个数区间长度2.将区间分为[l,mid]和[mid+1,r]分开毁掉(即分别获取[l,mid…
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base. Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Leng…
[链接] 我是链接,点我呀:) [题意] 横坐标1..2^n对应着2^n个复仇者的基地,上面有k个复仇者(位置依次给出). 你是灭霸你要用以下方法消灭这k个复仇者: 一开始你获取整个区间[1..2^n] 假设你当前获取的区间为[l,r] mid = (l+r)/2 那么你每次有两种选择 1.将整个区间全都毁掉,如果这个区间里没有复仇者,那么花费为A,否则花费为B复仇者个数区间长度 2.将区间分为[l,mid]和[mid+1,r]分开毁掉(即分别获取[l,mid]和[mid+1,r]这两个区间,然…
1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需要高效的随即存取,而不在乎插入和删除的效率,使用vector . (2)如果需要大量的插入和删除,而不关心随即存取,则应使用list . #include<bits/stdc++.h> #define F(i,a,b) for (int i=a;i<b;i++) #define FF(i,a…
Fox And Two Dots time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells…
D. Block Tower time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After too much playing on paper, Iahub has switched to computer games. The game he plays is called "Block Towers". It is…