当前位置:网站首页>[Supplementary Question Diary] [2022 Hangzhou Electric Summer School Multi-School 3] B-Boss Rush
[Supplementary Question Diary] [2022 Hangzhou Electric Summer School Multi-School 3] B-Boss Rush
2022-08-05 15:03:00 【cls1277】
Pro
https://acm.hdu.edu.cn/showproblem.php?pid=7163
Sol
This question didn't end thereA掉.Mainly because I'm too lazyBecause after reading the idea at that time, I wrote down what I thought was the correct solution,It also took several hours to find out how and how I wrote itstd的区别在哪,Therefore there is no further comparisonstd写一遍,Instead, spend that part of your time researching the idea and why it's wrong.
I don't think I understand the meaning of this question,I also slowly understood the idea of the questioner while writing and adjusting ,But monotonicity is still easy to see,So this question is a two-point answer.二分在xThe highest damage that can be hit in a frame,然后与HCompare whether the condition is met.
The problem is dichotomyjudge(check)函数怎么写:正确的做法为:因为最多只有18个技能,Therefore consider similar pressuresdp的方法,用 S S SDecimal numbers indicate status, f [ S ] f[S] f[S]Indicates the maximum damage that can be dealt in this state,So when enumerating S S S时,It can be done by judging whether the skill is in this state O ( 1 ) O(1) O(1)的转移,The specific implementation method is as followsstd.Therefore, it can be obtained by the cumulative calculation of the stateTCan it be played under the frameH的伤害,It can also be judgedTWhether the frame meets the condition.
And a wrong spelling is :No state transitions are made,for each state of the enumeration S S SBoth recalculate the maximum damage that can be played,So as to determine whether it can be playedH.But the recalculation method is wrong,It is not possible to calculate the corresponding state in a very short time S S S中为1Whether the skills corresponding to the subscripts need to be completed.pressuredpThe writing method can avoid this problem,through the accumulation of states,The one that reaches the current state is the optimal state,Just need to consider whether the current skills are all finished.
Below is elegantstd.
Code
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=18,M=100005;
int Case,n,i,j,S,t[N],d[N],l,r,ans,mid,sum[(1<<N)+1];
ll hp,f[(1<<N)+1],dmg[N][M];
inline void up(ll&a,ll b){
a<b?(a=b):0;}
bool check(int T){
int S,i;
for(S=0;S<1<<n;S++)f[S]=-1;
f[0]=0;
for(S=0;S<1<<n;S++){
ll w=f[S];
if(w<0)continue;
if(w>=hp) {
#ifdef DEBUG
cout<<T<<' '<<S<<endl;
#endif
return 1;
}
int cur=sum[S];
if(cur>T)continue;
for(i=0;i<n;i++)if(!(S>>i&1)){
if(cur+d[i]-1<=T)up(f[S|(1<<i)],w+dmg[i][d[i]-1]);
else up(f[S|(1<<i)],w+dmg[i][T-cur]);
}
}
return 0;
}
int main(){
#ifdef DEBUG
freopen("data.txt","r",stdin);
#endif
scanf("%d",&Case);
while(Case--){
scanf("%d%lld",&n,&hp);
ans=-1,l=r=0;
for(i=0;i<n;i++){
scanf("%d%d",&t[i],&d[i]);
r+=t[i]+d[i]-1;
for(j=0;j<d[i];j++)scanf("%lld",&dmg[i][j]);
for(j=1;j<d[i];j++)dmg[i][j]+=dmg[i][j-1];
}
for(S=1;S<1<<n;S++)sum[S]=sum[S-(S&-S)]+t[__builtin_ctz(S&-S)];
while(l<=r){
mid=(l+r)>>1;
if(check(mid))r=(ans=mid)-1;else l=mid+1;
}
printf("%d\n",ans);
}
}
边栏推荐
- Score-CAM|用kernel加权解释CNN的预测结果
- 【kali-Metasploit】Armitage常见问题:sudo权限、连接不到数据库、service not found
- 学习笔记180—回归系数与相关系数的关系和区别
- 20款短视频自媒体必备工具,让你的运营效率翻倍
- [FlareOn5] Ultimate Minesweeper WP
- Treasure Project(藏宝计划)冲刺百倍!
- Flexible and easy-to-use sql monitoring script part2
- 01.Gameplay Architecture ECS简介
- Matplotlib绘制直方图
- Deficiency needs attention
猜你喜欢

就是比某老师详细(反PPT系列)系列———自定义类型(下)

如何找回u盘里丢失的文件,u盘里的文件丢了怎么找回

软件开发模型与软件测试模型

Blow it up!The 1658-page trial summary of Ali Gaogong and 18 architects that took 57 days to integrate is too fragrant

训练好的神经网络怎么用,神经网络训练电脑配置

刷题《剑指Offer》day10

自媒体爆文如何写作?学会这4点,能让你快速提升阅读量

HDD Hangzhou Station • ArkUI makes development more flexible

If there are 10 words, and I want to take 3 words out of them, and record all possible stats for 3 out of 10, how do I do that?...

TCL基础入门
随机推荐
自媒体人必看的9个网站,每一个都很实用,值得收藏
全同胞家系如何计算遗传力及育种值
十五个AI图像放大工具
garbage collection mechanism
go语言的ini文件配置读取
请指教我想今天开户,可以么?手机开户安全么?
[WiFi] ebtable实现wifi接口之间数据隔离
概率论基础 - 9 - 中心极限定理
cookie, session, token
JS--如何编写事件驱动
environment file copy
mmap文件内存映射
playwright录制脚本
抖音自媒体账号被限流?这3种方法教你如何鉴别
d rebinding unchanged
umi3.5新特性之提速方案mfsu
概率论基础 - 12 - 拉普拉斯分布(Laplace分布)
基于rt-thread studio的STM32裸机开发第二节补充说明:OLED
就是比某老师详细(反PPT系列)系列———自定义类型(下)
正交-不相关-独立