• BZOJ 4716 假摔


    我们发现我们可以对每一个点维护其还没有用过的矩形中最小的几个,记得判重。

    #pragma GCC optimize("-O2")
    #include<bits/stdc++.h>
    using namespace std;
    #define sight(c) ('0'<=c&&c<='9')
    #define LL long long
    #define M 1007
    inline void read(int &x){
        static char c; static int b;
        for (b=1,c=getchar();!sight(c);c=getchar()) if (c=='-') b=-1;
        for (x=0;sight(c);c=getchar())x=x*10+c-48; x=x*b;
    }
    LL sum[M][M];
    struct state{
        int x,y,lx,ly;
        LL ans;
        state() {}
        state(int _x,int _y,int _lx,int _ly):x(_x),y(_y),lx(_lx),ly(_ly){
            ans=sum[_x-1+lx][_y-1+ly]+sum[_x-1][_y-1]-sum[_x-1+lx][_y-1]-sum[_x-1][_y-1+ly];
        }
        inline bool operator <(const state& P)const&{
            return
             P.ans==ans?
              (P.x==x?
               (P.y==y?
                (P.lx==lx?
                  P.ly<ly:
                   P.lx<lx):
                    P.y<y):
                     P.x<x):  
                      P.ans<ans;
        }
    }Now;
    #define N 2346007
    state hep[N];
    int len,n,m,xm,ym,K,ax;
    map<state,bool> mp;
    void write(LL x){if (x<10) {putchar('0'+x); return;} write(x/10); putchar('0'+x%10);}
    inline void writeln(LL x){ if (x<0) putchar('-'),x*=-1; write(x); putchar('
    '); }
    inline void writel(LL x){ if (x<0) putchar('-'),x*=-1; write(x); putchar(' '); }
    void put(state P){hep[++len]=P,push_heap(hep+1,hep+1+len);}
    inline state get() {pop_heap(hep+1,hep+1+len);return hep[len--];}
    signed main () {
        read(n); read(m); read(xm); read(ym); 
        read(K);
        for (int i=1;i<=n;i++)
         for (int j=1;j<=m;j++) read(ax),sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+ax;
        for (int i=1;i<=n-xm+1;i++)
         for (int j=1;j<=m-ym+1;j++)  put(state(i,j,xm,ym));
    //  for (int i=1;i<=len;i++) hep[i].we();
        while (K--) {
            while (Now=get(),1) {
                if (!mp[Now]) break;
            }
            mp[Now]=1;
    //      writel(Now.x); writel(Now.y); writel(Now.lx); writel(Now.ly); writeln(Now.ans);
            if (Now.x+Now.lx<=n) put(state(Now.x,Now.y,Now.lx+1,Now.ly));
            if (Now.y+Now.ly<=m) put(state(Now.x,Now.y,Now.lx,Now.ly+1));
        }
        writeln(Now.ans+1); return 0;
    }
  • 相关阅读:
    sikuli 安装
    pychar入门参考教材
    Jmeter 问题集
    appium 中文API 集
    执行Chrome自动化时--正在受到自动软件的控制的显示屏蔽
    下拉框选择
    发邮件 文字+ 附件的方法(QQ or 网易 邮箱)
    发送邮件(单独文字)的方法(网易邮箱 OR QQ邮箱)
    aapium 设置安卓机参数
    -循环点击遇到的坑(每次点击后返回,页面元素都会变化的解决方法)
  • 原文地址:https://www.cnblogs.com/rrsb/p/9255883.html
Copyright © 2020-2023  润新知