{"id":125,"date":"2010-02-23T22:28:00","date_gmt":"2010-02-23T14:28:00","guid":{"rendered":"http:\/\/localhost\/?p=125"},"modified":"2010-02-23T22:28:00","modified_gmt":"2010-02-23T14:28:00","slug":"sgu_415","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=125","title":{"rendered":"SGU 415"},"content":{"rendered":"\n<p><a target=\"_blank\" href=\"http:\/\/acm.sgu.ru\/problem.php?contest=0&amp;problem=415\">Problem<\/a><br \/>\u5c31\u662f\u8bf4\u7ed9\u4f60n\u4e2a\u786c\u5e01\uff0c\u7136\u540e\u8ba9\u4f60\u652f\u4ed8m\u7684\u8d27\u7269\uff0c\u8ba9\u4f60\u6c42\u51fa\u90a3\u4e9b\u786c\u5e01\u662f\u5fc5\u987b\u7684\u3002\u3002\u3001<br \/>n&lt;=200,m&lt;=10000<br \/>\u8fd9\u4e2a\u6570\u636e\u8303\u56f4\uff0c\u5982\u679c\u679a\u4e3e\u6bcf\u4e2a\u786c\u5e01\uff0c\u7136\u540e\u8ba1\u7b97\u7684\u5316\uff0c\u7edd\u5bf9\u4f1a\u60b2\u5267\uff0c<br \/>\u600e\u4e48\u529e\u5462\uff0c\u6211\u6ce8\u610f\u5230\u8981\u5c3d\u91cf\u5229\u7528\u8ba1\u7b97\u7684\u4fe1\u606f\uff0c<br \/>\u8bbeL[x]\u8868\u662f1-&gt;x-1\u8fd9\u4e9b\u786c\u5e01\u80fd\u652f\u4ed8\u7684\u94b1\u7684\u96c6\u5408\u3002<br \/>R[x]\u662fx+1-&gt;n\u8fd9\u4e9b\u786c\u5e01\u80fd\u652f\u4ed8\u7684\u94b1\u7684\u96c6\u5408\u3002<br \/>\u4f7f\u7528\u5e03\u5c14\u6570\u7ec4\u6216\u8005bitset\u6765\u8868\u793a\uff0c\u90a3\u4e48\u53ef\u4ee5\u5728O(nm)\u7b97\u51fa\u8fd9\u4e9b\u6570\u3002\u3002<br \/>\u7136\u540e\u68c0\u67e5\u7b2cx\u4e2a\u662f\u4e0d\u662f\u5fc5\u987b\u7684\u5c31\u5f88\u65b9\u4fbf\u4e86\uff0c\u53ef\u4ee5\u5728O(m)\u5b8c\u6210\u3002\u3002<br \/>Code\uff1a<\/p>\n<p>#include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;cstring&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)using namespace std;const int maxm=10000+1,maxn=200;int m,n;int A[maxn];struct Coins{    bool C[maxm];    int M;    Coins(){memset(C,0,sizeof(C));M=0;C[0]=true;}    void put(int x)    {        for(int i=M;i&gt;=0;&#8211;i)            if(C[i]&amp;&amp;i+x&lt;=m)                C[i+x]=true;        M+=x;M=min(M,m);    }    void operator=(const Coins&amp;o)    {        memmove(C,o.C,sizeof(C));        M=o.M;    }    bool&amp; operator[](int v){return C[v];}};Coins L[maxn],R[maxn];void init(){    cin&gt;&gt;n&gt;&gt;m;    rep(i,n) cin&gt;&gt;A[i];}void solve(){    Coins tmp;    for(int i=0;i&lt;n;i++)    {        L[i]=tmp;        tmp.put(A[i]);    }    tmp=Coins();    for(int i=n-1;i&gt;=0;&#8211;i)    {        R[i]=tmp;        tmp.put(A[i]);    }    vector&lt;int&gt; ans;    for(int i=0;i&lt;n;i++)    {        bool ok=false;        for(int x=0;x&lt;=m;x++)            if(L[i][x]&amp;&amp;R[i][m-x])            {                ok=true;break;            }        if(!ok) ans.push_back(A[i]);    }    cout&lt;&lt;ans.size()&lt;&lt;endl;    rep(i,ans.size()) cout&lt;&lt;ans[i]&lt;&lt;&quot; &quot;;}int main(){    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);    init();    solve();}<\/p>\n<p>\u672c\u9ad8\u4eae\u4ee3\u7801\u4f7f\u7528codeHl\u751f\u6210\uff0c<a target=\"_blank\" href=\"http:\/\/hi.baidu.com\/onlys_c\/blog\/item\/ef1149948c22d715d31b707e.html\">\u67e5\u770b\u8be6\u60c5<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem\u5c31\u662f\u8bf4\u7ed9\u4f60n\u4e2a\u786c\u5e01\uff0c\u7136\u540e\u8ba9\u4f60\u652f\u4ed8m\u7684\u8d27\u7269\uff0c\u8ba9\u4f60\u6c42\u51fa\u90a3\u4e9b\u786c\u5e01\u662f\u5fc5\u987b\u7684\u3002\u3002\u3001n&lt;=200,m&lt;=10000\u8fd9\u4e2a\u6570\u636e\u8303\u56f4\uff0c\u5982\u679c\u679a\u4e3e\u6bcf\u4e2a\u786c\u5e01\uff0c\u7136\u540e\u8ba1\u7b97\u7684\u5316\uff0c\u7edd\u5bf9\u4f1a\u60b2\u5267\uff0c\u600e\u4e48\u529e\u5462\uff0c\u6211\u6ce8\u610f\u5230\u8981\u5c3d\u91cf\u5229\u7528\u8ba1\u7b97\u7684\u4fe1\u606f\uff0c\u8bbeL[x]\u8868\u662f1-&gt;x-1\u8fd9\u4e9b\u786c\u5e01\u80fd\u652f\u4ed8\u7684\u94b1\u7684\u96c6\u5408\u3002R[x]\u662fx+1-&gt;n\u8fd9\u4e9b\u786c\u5e01\u80fd\u652f\u4ed8\u7684\u94b1\u7684\u96c6\u5408\u3002\u4f7f\u7528\u5e03\u5c14\u6570\u7ec4\u6216\u8005bitset\u6765\u8868\u793a\uff0c\u90a3\u4e48\u53ef\u4ee5\u5728O(nm)\u7b97\u51fa\u8fd9\u4e9b\u6570\u3002\u3002\u7136\u540e\u68c0\u67e5\u7b2cx\u4e2a\u662f\u4e0d\u662f\u5fc5\u987b\u7684\u5c31\u5f88\u65b9\u4fbf\u4e86\uff0c\u53ef\u4ee5\u5728O(m)\u5b8c\u6210\u3002\u3002Code\uff1a #include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;cstring&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)using namespace std;const int maxm=10000+1,maxn=200;int m,n;int A[maxn];struct Coins{ bool C[maxm]; int M; Coins(){memset(C,0,sizeof(C));M=0;C[0]=true;} void put(int x) { for(int i=M;i&gt;=0;&#8211;i) if(C[i]&amp;&amp;i+x&lt;=m) C[i+x]=true; M+=x;M=min(M,m); } void operator=(const Coins&amp;o) { memmove(C,o.C,sizeof(C)); M=o.M; } bool&amp; operator[](int v){return C[v];}};Coins L[maxn],R[maxn];void init(){ cin&gt;&gt;n&gt;&gt;m; rep(i,n) cin&gt;&gt;A[i];}void solve(){ Coins tmp; for(int i=0;i&lt;n;i++) { L[i]=tmp; tmp.put(A[i]); } tmp=Coins(); for(int i=n-1;i&gt;=0;&#8211;i) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/125"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=125"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/125\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}