zoukankan      html  css  js  c++  java
  • 【BZOJ4828】【HNOI2017】—大佬(LmyAKIOI!)

    传送门

    发现其实具体哪一天攻击并不重要
    我们首先只需要保证用最少的天数不死就可以了

    于是可以首先f[i][j]f[i][j]表示前ii天,信心为jj的最多的可以用来攻击的天数
    这个转移很简单

    那现在就变成了能不能用tt天时间击败大佬
    具体有哪些伤害也不好求出来
    只能用搜索来得到

    只攻击一次击败大佬是很好判断的
    假设有2次攻击,用时分别为dx,dydx,dy,伤害为fx,fyfx,fy
    那现在也就是要找到一个满足fx+fy<=c&&fx+fy+(tdxdy)>=cfx+fy<=c&&fx+fy+(t-dx-dy)>=c
    假设xx已经固定了,那也就是要找到最大的fydyfy-dy
    直接把所有攻击按伤害排序后双指针判定就可以了

    ljBZOJljBZOJ还不能用generategenerate

    #include<bits/stdc++.h>
    using namespace std;
    const int RLEN=1<<20|1;
    #define int long long
    inline char gc(){
    	static char ibuf[RLEN],*ib,*ob;
    	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    	return (ib==ob)?EOF:*ib++;
    }
    #define gc getchar
    inline int read(){
    	char ch=gc();
    	int res=0,f=1;
    	while(!isdigit(ch))f^=ch=='-',ch=gc();
    	while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    	return f?res:-res;
    }
    const int N=104;
    int n,m,mc;
    int a[N],w[N],c[N],t;
    struct node{
    	int pos,f,l;
    	node(int _pos=0,int _f=0,int _d=0):pos(_pos),f(_f),l(_d){}
    };
    #define pii pair<int,int>
    #define mk make_pair
    #define fi first
    #define se second
    map<pii,int> mp;
    pii g[1000005];
    int tot,mx;
    inline void chemx(int &a,int b){
    	a=a>b?a:b;
    }
    namespace sub1{
    	int f[N][N];
    	inline int solve(){
    		memset(f,0,sizeof(f));
    		for(int i=1;i<=n;i++){
    			for(int j=a[i];j<=mc;j++){
    				chemx(f[i][j-a[i]],f[i-1][j]+1);
    				chemx(f[i][min(mc,j-a[i]+w[i])],f[i-1][j]);
    			}
    		}
    		int res=0;
    		for(int j=1;j<=n;j++)for(int i=0;i<=mc;i++)res=max(res,f[j][i]);
    		return res;
    	}
    }
    void bfs(){
    	queue<node> q;
    	q.push(node(1,1,0));
    	while(!q.empty()){
    		node u=q.front();q.pop();
    		if(u.pos==t)continue;
    		q.push(node(u.pos+1,u.f,u.l+1));
    		if(u.l>1&&u.l*u.f<=mx&&!mp[mk(u.l*u.f,u.pos+1)]){
    			q.push(node(u.pos+1,u.f*u.l,u.l));
    			g[++tot]=pii(u.f*u.l,u.pos+1);
    			mp[mk(u.l*u.f,u.pos+1)]=1;
    		}
    	}
    
    }
    signed main(){
    	n=read(),m=read(),mc=read();
    	generate(a+1,a+n+1,read);
    	generate(w+1,w+n+1,read);
    	generate(c+1,c+m+1,read);
    	for(int i=1;i<=m;i++)chemx(mx,c[i]);
    	t=sub1::solve();
    	bfs();sort(g+1,g+tot+1);
    	for(int i=1;i<=m;i++){
    		if(c[i]<=t){puts("1");continue;}
    		bool flag=0;int mx=-1e9;
    		for(int j=tot,k=1;j>=1;j--){
    			while(k<tot&&g[k].fi+g[j].fi<=c[i])
    				chemx(mx,g[k].fi-g[k].se),k++;
    			if(g[j].fi-g[j].se+t+mx>=c[i]){flag=1;break;}
    			if(g[j].fi<=c[i]&&g[j].fi-g[j].se+t>=c[i]){flag=1;break;}
    		}
    		if(flag)puts("1");
    		else puts("0");
    	}
    }
    
  • 相关阅读:
    正则函数及面向对象开发初识---day19
    正则计算器---day19
    正则表达式re模块---day18
    批量下载英雄联盟官网皮肤及打包
    zip压缩模块,tarfile压缩模块,包和模块,format格式化的复习--day17
    计算一个文件夹里面所有文件的大小---day17
    time模块,os操作系统及os模块和shutil模块用法---day16
    http请求方法
    cube.js
    http响应码
  • 原文地址:https://www.cnblogs.com/stargazer-cyk/p/11145567.html
Copyright © 2011-2022 走看看