首页 > 其他分享 >Why WA?

Why WA?

时间:2023-05-01 18:44:14浏览次数:39  
标签:ch WA int lowbit 1200 ret read Why

Acwing 292 炮兵阵地

状压dp

#include <bits/stdc++.h>
#define int long long
#define itn int
using namespace std;
int read()
{
    int x=1,a=0;
    char ch=getchar();
    while(ch>'9' || ch<'0')x=(ch=='-')?-1:x,ch=getchar();
    while(ch>='0' && ch<='9')a=(a<<1)+(a<<3)+(ch-'0'),ch=getchar();
    return a*x;
}
vector<int> could;
int n,m;
int mmap[15];
int f[2][1200][1200],cnt[1200];
int lowbit(int x)
{
    return x&(-x);
}
inline int have(int x)
{
    int ret=0;
    while(lowbit(x)!=0)
    {
        ret++;
        x-=lowbit(x);
    }
    return ret;
}
char s[15];
signed main()
{
    n=read(),m=read();
    for(int i=1;i<=n;i++)
    {
        cin>>(s+1);
        for(int j=1;j<=m;j++)
        {
            mmap[i]=(mmap[i]<<1)+(s[j]=='H');
        }
    }
    for(int i=0;i<(1<<m);i++)
    {
        if(!((i&(i>>1))||(i&(i>>2))))
        {
            could.push_back(i);
            cnt[i]=have(i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(auto now:could)
        {
            if(!(now&mmap[i]))
            for(auto last:could)
            {
                if(!(now&last))
                for(auto last_2:could)
                {
                    if((!(now&last_2))&&(!(last&last_2)))
                    {
                        f[i&1][now][last]=max(f[i&1][now][last],f[(i-1)&1][last][last_2]+cnt[now]);
                    }
                }
            }
        }
    }
    int ans=0;
    for(auto i:could)
    {
        for(auto j:could)
        {
            ans=max(ans,f[n&1][i][j]);
        }
    }
    cout<<ans;
}

 

标签:ch,WA,int,lowbit,1200,ret,read,Why
From: https://www.cnblogs.com/Ga1ahad-and-Scientific-Witchery/p/17366835.html

相关文章

  • Vmware虚拟机开机就蓝屏解决办法
    概要在升级到了Windows1021H1之后,Vmware开启虚拟机电源的瞬间一定会蓝屏,虽然没有试过vituralBox之类的,但是应该情况一样。解决办法解决办法其实很简单,首先打开控制面板,找到卸载程序,然后点击左侧的“启用或关闭Windows功能”,找到最下面的“虚拟机平台”,勾选重启后即可。......
  • 把任意Drawable转换成基于progress填充的drawable
    把任意Drawable转换成基于progress填充的drawable。progress可以是四个方向:from_left,from_top,from_right,from_bottom。FillDrawable的背后是PorterDuffColorFilter//obtainaDrawableobjectfinalDrawabledrawable=getDrawable(...);//initializeboundsdraw......
  • LayerDrawable层叠样式layer-list
    layer-list可以将多个图片按照顺序层叠起来。语法:在drawalbe/drawable-layer.xml中<layer-listxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:drawable="@android:color/white"/><itemand......
  • Vulnhub之Gears of War靶机详细测试过程
    GearofWar识别目标主机IP地址─(kali㉿kali)-[~/Vulnhub/Gearofwar]└─$sudonetdiscover-ieth1-r192.168.56.0/24Currentlyscanning:Finished!|ScreenView:UniqueHosts......
  • OpenResty学习笔记02:为服务增加waf功能
    一.WAF简介 Web应用防护系统(也称为:网站应用级入侵防御系统。英文:WebApplicationFirewall,简称:WAF)。目前国内的几大云服务商都提供了企业级的WAF产品,且均价格不菲。好消息是,在OpenResty生态中,有一款开源的WAF可供我等学习,开源万岁! 二.开源的WAF 该WAF的作者叫赵......
  • springboot2.7.10集成swagger3.0 (springboot版本和swagger是有版本搭配的吗)
    springboot2.7.10集成swagger3.0https://blog.csdn.net/TuringZGJ/article/details/129832851  springboot版本和swagger是有版本搭配的吗 SpringbootSwagger各版本整理https://blog.csdn.net/m0_67401746/article/details/126506471 ......
  • 《asyncio 系列》4. 如何并发运行多个任务(asyncio.gather、asyncio.as_completed、asy
    楔子在上一篇文章中,我们了解了套接字的内部工作原理,并构建了一个基本的回显服务器。现在我们将学到的知识应用到并发的、非阻塞的Web请求中,基于asyncio可以并发发送大量的Web请求,缩短应用程序的运行时间。当我们必须向一组RESTAPI发出多个请求时,这很有用,比如在微服务架......
  • c++11:std::forward,完美转发
    目录1、不完美转发2、完美转发2.1、引用折叠2.2、std::forward1、不完美转发所谓完美转发,是指在函数模板中,完全按照模板的参数的类型,将参数传递给函数模板中调用的另一个函数。比如:template<typenameT>voidIamForwording(Tt){IrunCodeActually(t);}上面的例子中,IamF......
  • 使用SAM(Segment Anything Model)查找Waldo
    你知道你可以教#GPT3找到Waldo吗? ......
  • C++之forward
    不管是T&&、左值引用、右值引用,std::forward都会按照原来的类型完美转发。forward主要解决引用函数参数为右值时,传进来之后有了变量名就变成了左值。 #include<QCoreApplication>#include<memory>#include<iostream>usingnamespacestd; template<typenameT>void......