{"id":567,"date":"2019-01-11T17:05:14","date_gmt":"2019-01-11T09:05:14","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=567"},"modified":"2019-03-14T16:50:19","modified_gmt":"2019-03-14T08:50:19","slug":"lp2468-sdoi2010-%e7%b2%9f%e7%b2%9f%e7%9a%84%e4%b9%a6%e6%9e%b6","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2019\/01\/11\/lp2468-sdoi2010-%e7%b2%9f%e7%b2%9f%e7%9a%84%e4%b9%a6%e6%9e%b6\/","title":{"rendered":"lp2468 SDOI2010 \u7c9f\u7c9f\u7684\u4e66\u67b6"},"content":{"rendered":"\n<p>\u7b80\u5316\u9898\u610f\u3002<br> \u6709\u4e00\u4e2an*m\u7684\u77e9\u9635\uff0cq\u4e2a\u8be2\u95ee\uff0c\u6c42\u95ee\uff0c\u5728\u6bcf\u4e2a\u77e9\u9635\u4e2d\u6700\u5c11\u53d6\u591a\u5c11\u4e2a\u6570\uff0c\u4f7f\u5f97\u548c\u81f3\u5c11\u4e3ah\u3002<br> \u89c2\u5bdf\u6570\u636e\u8303\u56f4\uff0c\u6211\u4eec\u60ca\u8bb6\u5730\u53d1\u73b0\u8fd9\u4e00\u9898\u4e0d\u53ef\u907f\u514d\u5730\u8981\u505a\u4e24\u6b21\u3002<br> \u56e0\u4e3a\uff0cn,m&lt;=200\u663e\u7136\u4e0d\u662f\u7528\u666e\u901a\u7684\u6570\u636e\u7ed3\u6784\u53ef\u4ee5\u7ef4\u62a4\u7684\u3002\u6211\u4eec\u8003\u8651\u4f7f\u7528\\(cnt_{i,j,k}\\)\u8868\u793a\u5927\u4e8ek\u7684\u6570\u7684\u6570\u91cf\uff0c\\(sm_{i,j,k}\\)\u8868\u793a\u5927\u4e8ek\u7684\u6570\u7684\u603b\u548c\u3002\u7136\u540e\u4e8c\u5206\u8fd9\u4e2ak\u6765\u6c42\u89e3\u5373\u53ef\u3002<br> \u5bf9\u4e8en==1\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u5f88\u5bb9\u6613\u53ef\u4ee5\u60f3\u5230\u7ef4\u62a4\u4e00\u68f5\u6743\u503c\u4e3b\u5e2d\u6811\u3002\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u8be2\u95ee\uff0c\u6211\u4eec\u5728\u4e24\u68f5\u6743\u503c\u7ebf\u6bb5\u6811\u4e0a\u4e8c\u5206\u7136\u540e\u6c42\u5dee\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#define MID ((L+R)>>1)\nint n,m,q;\nint b[205][205],cnt[205][205][1005],sm[205][205][1005];\n\/\/\u4e0d\u9700\u8981\u5f00longlong\uff01\uff01\uff01MLE\u8b66\u544a\uff01\uff01\uff01 \n\ninline long long cntQry(int X1,int Y1,int X2,int Y2,int K){\n    return cnt[X2][Y2][K]-cnt[X1-1][Y2][K]-cnt[X2][Y1-1][K]+cnt[X1-1][Y1-1][K];\n}\ninline long long smQry(int X1,int Y1,int X2,int Y2,int K){\n    return sm[X2][Y2][K]-sm[X1-1][Y2][K]-sm[X2][Y1-1][K]+sm[X1-1][Y1-1][K];\n}\ninline void slv2(){\n    for(int i=1;i&lt;=n;++i){\n        for(int j=1;j&lt;=m;++j){\n            scanf(\"%d\",&amp;b[i][j]);\n        }\n    }\n    for(int k=0;k&lt;=1000;++k){\n        for(int i=1;i&lt;=n;++i){\n            for(int j=1;j&lt;=m;++j){\n                cnt[i][j][k]=cnt[i-1][j][k]+cnt[i][j-1][k]-cnt[i-1][j-1][k]+(int)(b[i][j]>=k);\n                sm[i][j][k]=sm[i-1][j][k]+sm[i][j-1][k]-sm[i-1][j-1][k]+(int)(b[i][j]>=k)*b[i][j];\n            }\n        }\n    }\n    long long l,r,mid,h,ans;\n    int X1,X2,Y1,Y2;\n    while(q--){\n        l=0,r=1001,ans=-1;\n        scanf(\"%d%d%d%d%lld\",&amp;X1,&amp;Y1,&amp;X2,&amp;Y2,&amp;h);\n        while(l&lt;=r){\n            mid=(l+r)>>1,smQry(X1,Y1,X2,Y2,mid)>=h?(ans=mid,l=mid+1):r=mid-1;\n        }\n        (~ans)?(printf(\"%lld\\n\",cntQry(X1,Y1,X2,Y2,ans)-(smQry(X1,Y1,X2,Y2,ans)-h)\/ans)):(puts(\"Poor QLW\"));\n    }\n    \n\/\/\t \u5bf9\u4e8e\u540c\u4e00\u4e2ak\u53ef\u80fd\u6709\u591a\u4e2a\u503c\uff0c\u800c\u53ef\u80fd\u53ea\u9700\u8981\u9009\u53d6\u90e8\u5206\u3002 \n}\nconst int MAXN2=10000005;\nint a[MAXN2];\n\/\/\u6570\u7ec4\u5927\u5c0f\u522b\u7b97\u9519 \nclass ChairmanTree{\n    private:\n        class Node{\n            public:\n                int l;\n                int r;\n                int fa;\n                int sz;\n                int sm;\n        };\n        Node tr[MAXN2];\n        int cnt,rt[MAXN2];\n        inline void build(int LST,int &amp;NW,int L,int R,int V){\n            NW=++cnt;tr[NW].sz=tr[LST].sz+1;tr[NW].sm=tr[LST].sm+V;\n            if(L==R){return;}\n            MID>=V?(build(tr[LST].l,tr[NW].l,L,MID,V),tr[NW].r=tr[LST].r):(build(tr[LST].r,tr[NW].r,MID+1,R,V),tr[NW].l=tr[LST].l);\n            \/\/\u5982\u679c\u503c\u5c0f\u7b49\u4e8eMID\u3002\u90a3\u4e48\u5c31\u66f4\u65b0\u53f3\u8fb9\u7684\u503c\uff1b\u5426\u5219\u66f4\u65b0\u5de6\u8fb9\u7684\u503c\u3002\u4e00\u5b9a\u8981\u6ce8\u610f\u5224\u65adV==MID\u65f6\u7684\u60c5\u51b5\u3002 \n            \/\/\u5982\u679c\u66f4\u65b0\u7684\u662f\u53f3\u8fb9\u7684\u503c\uff0c\u90a3\u4e48\u5c31\u628a\u53f3\u8fb9\u7684\u8282\u70b9\u4e0e\u4e0a\u4e00\u4e2a\u7248\u672c\u7684\u53f3\u8fb9\u7684\u8282\u70b9\u4e00\u5e76\u4e0b\u4f20\uff0c\u5e76\u4fee\u6539\u672c\u8282\u70b9\u7684\u5de6\u8282\u70b9\uff1b\u5426\u5219\u53cd\u4e4b\u3002 \n        }\n        \/\/\u4ece\u6839\u5f80\u4e0b\u641c\u7d22\u3002\u6ce8\u610f\u51cf\u53bb\u7684\u5e94\u5f53\u662f\u53f3\u8282\u70b9\u7684\u503c\u3002 \n        inline int qry(int A,int B,int L,int R,int V){\n            int RT=0;\n            while(L&lt;R){(tr[tr[B].r].sm-tr[tr[A].r].sm)>V?(L=MID+1,B=tr[B].r,A=tr[A].r):(RT+=tr[tr[B].r].sz-tr[tr[A].r].sz,V-=(tr[tr[B].r].sm-tr[tr[A].r].sm),R=MID,B=tr[B].l,A=tr[A].l);}\n            \/\/\u540c\u7406\uff0c\u5bf9\u4e8e\u7b49\u4e8e\u7684\u60c5\u51b5\u4e5f\u5e94\u5f53\u7279\u522b\u6ce8\u610f\u3002 \n            return RT+(V+L-1)\/(L);\n            \/\/\u5269\u4e0b\u7684\u90e8\u5206\u5e94\u8be5\u5168\u90e8\u7531\u5927\u5c0f\u4e3aR\u7684\u8fd9\u4e9b\u4e1c\u897f\uff0c\u4e5f\u5c31\u662f\u5f53\u524d\u70b9\u7684\u503c\u6765\u5904\u7406\u6389\u3002\u6545\u800c\u8981\u52a0\u4e0a(V+L-1)\/(L)\n        }\n    public:\n        inline void ADD(int VER,int X){\n            build(rt[VER-1],rt[VER],1,1000,X);\n        }\n        inline int QUREY(int LVER,int RVER,int X){\n            return qry(rt[LVER-1],rt[RVER],1,1000,X);\n        }\n        inline int SUM(int L,int R){\n            return tr[rt[R]].sm-tr[rt[L-1]].sm;\n        }\n        inline void INIT(){\n            cnt=0;\n        }\n};\nChairmanTree T;\ninline void slv1(){\n    T.INIT();\n    for(int i=1;i&lt;=m;++i){\n        scanf(\"%d\",&amp;a[i]);\n        T.ADD(i,a[i]);\n    }\n    int l,r,tmp,x;\n    while(q--){\n        scanf(\"%d%d%d%d%d\",&amp;tmp,&amp;l,&amp;tmp,&amp;r,&amp;x);\n        if(T.SUM(l,r)&lt;x){\n            puts(\"Poor QLW\");\n            continue;\n        }\n        printf(\"%d\\n\",T.QUREY(l,r,x));\n    }\n}\n\nvoid init(){\n    scanf(\"%d%d%d\",&amp;n,&amp;m,&amp;q);\n    n==1?slv1():slv2();\n}\n\nint main(){\n    init();\n    return 0;\n} <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u5316\u9898\u610f\u3002 \u6709\u4e00\u4e2an*m\u7684\u77e9\u9635\uff0cq\u4e2a\u8be2\u95ee\uff0c\u6c42\u95ee\uff0c\u5728\u6bcf\u4e2a\u77e9\u9635\u4e2d\u6700\u5c11\u53d6\u591a\u5c11\u4e2a\u6570\uff0c\u4f7f\u5f97\u548c\u81f3\u5c11\u4e3ah\u3002 \u89c2\u5bdf\u6570\u636e\u8303\u56f4\uff0c\u6211 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2019\/01\/11\/lp2468-sdoi2010-%e7%b2%9f%e7%b2%9f%e7%9a%84%e4%b9%a6%e6%9e%b6\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp2468 SDOI2010 \u7c9f\u7c9f\u7684\u4e66\u67b6\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[79,34,43,49,8,9,6,48,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/567"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=567"}],"version-history":[{"count":2,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/567\/revisions"}],"predecessor-version":[{"id":711,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/567\/revisions\/711"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=567"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}