{"id":350,"date":"2010-08-22T02:12:00","date_gmt":"2010-08-21T18:12:00","guid":{"rendered":"http:\/\/localhost\/?p=350"},"modified":"2010-08-22T02:12:00","modified_gmt":"2010-08-21T18:12:00","slug":"zjoi2009_staining_game","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=350","title":{"rendered":"[ZJOI2009]\u67d3\u8272\u6e38\u620f"},"content":{"rendered":"\n<p>[ZJOI2009]\u67d3\u8272\u6e38\u620f<\/p>\n<p>Time Limit:5000MS&#160; Memory Limit:65536K<br \/>Total Submit:22 Accepted:13 <br \/>Case Time Limit:1000MS<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> \u4e00\u5171n \u00d7 m \u4e2a\u786c\u5e01\uff0c\u6446\u6210n \u00d7 m \u7684\u957f\u65b9\u5f62\u3002dongdong \u548cxixi \u73a9\u4e00\u4e2a\u6e38\u620f\uff0c <br \/>\u6bcf\u6b21\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u8fde\u901a\u5757\uff0c\u5e76\u628a\u5176\u4e2d\u7684\u786c\u5e01\u5168\u90e8\u7ffb\u8f6c\uff0c\u4f46\u662f\u9700\u8981\u6ee1\u8db3\u5b58\u5728\u4e00\u4e2a <br \/>\u786c\u5e01\u5c5e\u4e8e\u8fd9\u4e2a\u8fde\u901a\u5757\u5e76\u4e14\u6240\u6709\u5176\u4ed6\u786c\u5e01\u90fd\u5728\u5b83\u7684\u5de6\u4e0a\u65b9(\u53ef\u4ee5\u6b63\u5de6\u65b9\u4e5f\u53ef\u4ee5\u6b63 <br \/>\u4e0a\u65b9)\uff0c\u5e76\u4e14\u8fd9\u4e2a\u786c\u5e01\u662f\u4ece\u53cd\u9762\u5411\u4e0a\u7ffb\u6210\u6b63\u9762\u5411\u4e0a\u3002dongdong \u548cxixi \u8f6e\u6d41\u64cd\u4f5c\u3002 <br \/>\u5982\u679c\u67d0\u4e00\u65b9\u65e0\u6cd5\u64cd\u4f5c\uff0c\u90a3\u4e48\u4ed6(\u5979) \u5c31\u8f93\u4e86\u3002dongdong \u5148\u8fdb\u884c\u7b2c\u4e00\u6b65\u64cd\u4f5c\uff0c\u5047 <br \/>\u8bbe\u53cc\u65b9\u90fd\u91c7\u7528\u6700\u4f18\u7b56\u7565\u3002\u95eedongdong \u662f\u5426\u6709\u5fc5\u80dc\u7b56\u7565\u3002<\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u7b2c\u4e00\u884c\u4e00\u4e2a\u6570T\uff0c\u8868\u793a\u4ed6\u4eec\u4e00\u5171\u73a9T \u5c40\u6e38\u620f\u3002\u63a5\u4e0b\u6765\u662fT \u7ec4\u6e38\u620f\u63cf\u8ff0\u3002\u6bcf <br \/>\u7ec4\u6e38\u620f\u7b2c\u4e00\u884c\u4e24\u4e2a\u6570n;m\uff0c\u63a5\u4e0b\u6765n \u884c\u6bcf\u884cm \u4e2a\u5b57\u7b26\uff0c\u7b2ci \u884c\u7b2cj \u4e2a\u5b57\u7b26\u5982 <br \/>\u679c\u662f\u201cH\u201d \u8868\u793a\u7b2ci \u884c\u7b2cj \u5217\u7684\u786c\u5e01\u662f\u6b63\u9762\u5411\u4e0a\uff0c\u5426\u5219\u662f\u53cd\u9762\u5411\u4e0a\u3002\u7b2ci \u884cj \u5217 <br \/>\u7684\u5de6\u4e0a\u65b9\u662f\u6307\u884c\u4e0d\u8d85\u8fc7i \u5e76\u4e14\u5217\u4e0d\u8d85\u8fc7j \u7684\u533a\u57df\u3002<\/p>\n<p><strong>Output <\/strong><\/p>\n<p> \u5bf9\u4e8e\u6bcf\u5c40\u6e38\u620f\uff0c\u8f93\u51fa\u4e00\u884c\u3002\u5982\u679cdongdong \u5b58\u5728\u5fc5\u80dc\u7b56\u7565\u5219\u8f93\u51fa\u201c- -\u201d(\u4e0d\u542b <br \/>\u5f15\u53f7) \u5426\u5219\u8f93\u51fa\u201c= =\u201d(\u4e0d\u542b\u5f15\u53f7)\u3002(\u6ce8\u610f\u8f93\u51fa\u7684\u90fd\u662f\u534a\u89d2\u7b26\u53f7\uff0c\u5373\u4e09\u4e2a\u7b26\u53f7 <br \/>ASCII \u7801\u5206\u522b\u4e3a45,61,95) <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>32<br \/>3<br \/>HHH<br \/>HHH<br \/>2 3<br \/>HHH<br \/>TTH<br \/>2 1<br \/>T<br \/>H<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>= =<br \/>&#8211; &#8211;<br \/>&#8211; &#8211;<\/p>\n<p><strong>Hint <\/strong><\/p>\n<p> \u5bf9\u4e8e40% \u7684\u6570\u636e\uff0c\u6ee1\u8db31 \u2264 n;m \u2264 5\u3002 <br \/>\u5bf9\u4e8e100% \u7684\u6570\u636e\uff0c\u6ee1\u8db31 \u2264 n;m \u2264 100\uff0c1 \u2264 T \u2264 50\u3002 <\/p>\n<p><strong>Source<br \/>\u8fd9\u4e2a\u9898\u76ee\u4e00\u770b\u5c31\u77e5\u9053\u662f\u8981\u7b97SG\u51fd\u6570\u7684\u7834\u9898\u3002\u3002\u5f88\u591a\u5e74<br \/>\u4ee5\u524d\u6211\u770b\u5230\u8fd9\u9898\u5c31\u54c6\u55e6\u56e7\u3002\u3002\u4e0d\u8fc7\u4eca\u5929\u7814\u7a76\u4e86\u4e00\u4e2a\u665a\u4e0a<br \/>\u5404\u79cd\u6587\u732e\u7b97\u662f\u4f1a\u505a\u4e86\u7011\u5e03\u6c57\u3002\u3002\u3002<br \/>\u9996\u5148\u80af\u5b9a\u662f\u8981\u7b97SG\u51fd\u6570\u503c\u7684\uff0c\u8bbe\u70b9(x,y)\u7684\u51fd\u6570\u503c\u4e3aF(x,y)<br \/>\u5148\u8bc1\u4e2a\u597d\u8bc1\u7684\uff1a<br \/>\u5f53x\u548cy\u90fd\u5927\u4e8e0\u7684\u65f6\u5019\uff0cF(x,y)=2^(x+y)..<br \/>\u7ec8\u6001\u5c31\u662f\u6ca1\u6709\u4e00\u4e2aT\u56e7\u3002\u3002SG\uff08\u7ec8\u6001\uff09=0<br \/>\u9996\u5148\u4f7f\u7528\u5f52\u7eb3\u6cd5\uff0c\u4e3a\u4e86\u65b9\u4fbf\u5427(0,0),(0,1),(1,0)\u4e5f\u8003\u8651\u8fdb\u53bb\uff0c<br \/>\u8fd9\u4e9b\u70b9\u663e\u7136\u6ee1\u8db3\u6761\u4ef6\u3002\u3002<br \/>\u7136\u540e\u5f00\u59cb\u7528x+y=k,\u6309k\u5f52\u7eb3\u3002\u3002<br \/>\u5047\u8bbek-1\u6ca1\u95ee\u9898\u4e86\u3002\u3002<br \/>\u90a3\u4e48\u8981\u8bc1\u660ek\u7684\u8bdd\uff0c\u5c31\u8981\u8bc1\u660e\u4ee5(x,y)\u4e3a\u6700\u53f3\u4e0b\u7684\u6709\u8054\u901a\u5757\u7684SG\u503c\u4e3a0..2^(x+y)-1,\u4e14\u6ca1\u67092^(x+y)\u3002\u3002<br \/>\u540e\u8005\u662f\u663e\u7136\u7684\uff0c\u56e0\u4e3a\uff08x\uff0cy\uff09\u662f\u6700\u53f3\u4e0b\uff0c\u6240\u4ee5\u5176\u5b83\u7684\u70b9\u5728x+y\u8fd9\u4f4d\u4e0a\u90fd\u662f0\u3002\u3002\u600e\u4e48\u4e5f\u4e0d\u4f1a\u5f04\u51fa\u4e2a2^(x+y)\u3002<br \/>\u524d\u8005\u4e5f\u53ef\u4ee5\u6784\u9020\u51fa\u6765\u3002\u3002\u5177\u4f53\u7684\u8bf4\u5c31\u662f\u7ed9\u5b9a\u4e2a\u6570X\uff0c\u5982\u679c\u5b83\u5728\u7b2ci\u4f4d\u4e0a\u662f0\uff0c\u90a3\u4e48\u6211\u5c31\u5728x+y=i\u90a3\u6761\u7ebf\u4e0a\u5f04\u4e24\u4e2a\u70b9\uff0c\u5426\u5219\u5c31\u5f04\u4e00\u4e2a\u3002\u3002YY\u4e00\u4e0b\u5c31\u53ef\u4ee5\u4e86\u3002\u3002<br \/>\u518d\u8bc1\u4e2a\u9ebb\u70e6\u7684\u3002\u3002<br \/>\u5f53x=0\u6216y=0\u7684\u65f6\u5019\uff0c\u663e\u7136\u4e0a\u9762\u5bf9\u8bc1\u6cd5\u5c31\u4e0d\u80fd\u6210\u7acb\u56e7\u3002\u3002<br \/>\u4f46\u6b64\u65f6\u5df2\u7ecf\u53d8\u6210\u4e00\u4e2a\u7ecf\u5178\u7684\u4e00\u7ef4\u95ee\u9898\u4e86\uff0c\u51b3\u7b56\u4e5f\u662fO\uff08N\uff09<br \/>\u7684\u3002\u3002\u6240\u4ee5\u5f04\u4e2aN^2\u7684Dp\u7b97\u4e0bSG\u503c\u5c31\u53ef\u4ee5\u4e86\u3002\u3002<br \/>\u4e0d\u8fc7\u8fd8\u662f\u8bb2\u4e00\u4e0b\u66f4\u52a0\u6570\u5b66\u5316\u7684\u505a\u6cd5\u5427\uff0c<br \/>\u8fd9\u4e2a\u95ee\u9898\u53ebRuler\u6e38\u620f\u3002\u3002<br \/>\u5c31\u662f\u7ed9\u4f60\u4e00\u6761\u786c\u5e01\uff0c\u6bcf\u6b21\u7ffb\u8fde\u7eed\u7684\u4e00\u6bb5\uff0c\u6700\u540e\u4e00\u4e2a\u4e00\u5b9a\u662f\u7531<br \/>\u53cd\u9762\u5230\u6b63\u9762\u3002\u3002<br \/>\u8bbeF(x)\u4e3a\u7b2cx\u4e2a\u786c\u5e01\u7684SG\u503c\u3002\u3002<br \/>\u90a3\u4e48\u53ef\u4ee5\u8bc1\u660eF(x)\u4e3a\u53ef\u4ee5\u5c06x\u6574\u9664\u76842\u7684\u6700\u5927\u5e42\u3002\u3002<br \/>\u7528\u5f52\u7eb3\u6cd5\u641e\u4e00\u4e0b\u5c31\u53ef\u4ee5\u4e86\u3002\u3002\u3002<br \/>\u8bdd\u8bf4\u8fd9\u4e2a\u9898\u76ee\u771fTMD\u7325\u7410\u3002\u3002\u8f93\u51fa\u4e0d\u5bf9\u7684\u3002\u3002<br \/>\u770b\u54ea\u4e2aASCII\u7684\u53f7\u7801\u7684\u8bdd\u5e94\u8be5\u662f=_=he-_-\u624d\u5bf9\u554a\u56e7\u3002\u3002\u3002<br \/>Code\uff1a<br \/><\/strong><\/p>\n<p>#include &lt;cstdio&gt;<br \/>#include &lt;cstring&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>const int inf=~0U&gt;&gt;1,maxn=105;<br \/>using namespace std;<br \/>inline int lowbit(int x){return x&amp;-x;}<br \/>int log(int x){return x==1?0:(log(x\/2)+1);}<br \/>int n,m;<br \/>int sg(int x,int y)<br \/>{<br \/>    if(x==0||y==0)return log(lowbit(x+y+1));<br \/>    return x+y;<br \/>}<br \/>bool E[maxn*2]={};<br \/>int main()<br \/>{<br \/>    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    int T;scanf(&quot;%d&quot;,&amp;T);<br \/>    rep(t,T)<br \/>    {<br \/>        scanf(&quot;%d%d&quot;,&amp;n,&amp;m);<br \/>        memset(E,0,sizeof E);<br \/>        rep(i,n)<br \/>        {<br \/>            scanf(&quot; &quot;);<br \/>            rep(j,m)<br \/>            {<br \/>                char c=getchar();<br \/>                if(c==&#8217;T&#8217;)<br \/>                    E[sg(i,j)]^=1;<br \/>            }<br \/>        }<br \/>        bool ok=true;<br \/>        rep(i,n+m)if(E[i]){ok=false;break;}<br \/>        if(ok)puts(&quot;=_=&quot;);<br \/>        else puts(&quot;-_-&quot;);<br \/>    }<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ZJOI2009]\u67d3\u8272\u6e38\u620f Time Limit:5000MS&#160; Memory Limit:65536KTotal Submit:22 Accepted:13 Case Time Limit:1000MS Description \u4e00\u5171n \u00d7 m \u4e2a\u786c\u5e01\uff0c\u6446\u6210n \u00d7 m \u7684\u957f\u65b9\u5f62\u3002dongdong \u548cxixi \u73a9\u4e00\u4e2a\u6e38\u620f\uff0c \u6bcf\u6b21\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u8fde\u901a\u5757\uff0c\u5e76\u628a\u5176\u4e2d\u7684\u786c\u5e01\u5168\u90e8\u7ffb\u8f6c\uff0c\u4f46\u662f\u9700\u8981\u6ee1\u8db3\u5b58\u5728\u4e00\u4e2a \u786c\u5e01\u5c5e\u4e8e\u8fd9\u4e2a\u8fde\u901a\u5757\u5e76\u4e14\u6240\u6709\u5176\u4ed6\u786c\u5e01\u90fd\u5728\u5b83\u7684\u5de6\u4e0a\u65b9(\u53ef\u4ee5\u6b63\u5de6\u65b9\u4e5f\u53ef\u4ee5\u6b63 \u4e0a\u65b9)\uff0c\u5e76\u4e14\u8fd9\u4e2a\u786c\u5e01\u662f\u4ece\u53cd\u9762\u5411\u4e0a\u7ffb\u6210\u6b63\u9762\u5411\u4e0a\u3002dongdong \u548cxixi \u8f6e\u6d41\u64cd\u4f5c\u3002 \u5982\u679c\u67d0\u4e00\u65b9\u65e0\u6cd5\u64cd\u4f5c\uff0c\u90a3\u4e48\u4ed6(\u5979) \u5c31\u8f93\u4e86\u3002dongdong \u5148\u8fdb\u884c\u7b2c\u4e00\u6b65\u64cd\u4f5c\uff0c\u5047 \u8bbe\u53cc\u65b9\u90fd\u91c7\u7528\u6700\u4f18\u7b56\u7565\u3002\u95eedongdong \u662f\u5426\u6709\u5fc5\u80dc\u7b56\u7565\u3002 Input \u7b2c\u4e00\u884c\u4e00\u4e2a\u6570T\uff0c\u8868\u793a\u4ed6\u4eec\u4e00\u5171\u73a9T \u5c40\u6e38\u620f\u3002\u63a5\u4e0b\u6765\u662fT \u7ec4\u6e38\u620f\u63cf\u8ff0\u3002\u6bcf \u7ec4\u6e38\u620f\u7b2c\u4e00\u884c\u4e24\u4e2a\u6570n;m\uff0c\u63a5\u4e0b\u6765n \u884c\u6bcf\u884cm \u4e2a\u5b57\u7b26\uff0c\u7b2ci \u884c\u7b2cj \u4e2a\u5b57\u7b26\u5982 \u679c\u662f\u201cH\u201d \u8868\u793a\u7b2ci \u884c\u7b2cj \u5217\u7684\u786c\u5e01\u662f\u6b63\u9762\u5411\u4e0a\uff0c\u5426\u5219\u662f\u53cd\u9762\u5411\u4e0a\u3002\u7b2ci \u884cj \u5217 \u7684\u5de6\u4e0a\u65b9\u662f\u6307\u884c\u4e0d\u8d85\u8fc7i \u5e76\u4e14\u5217\u4e0d\u8d85\u8fc7j \u7684\u533a\u57df\u3002 Output \u5bf9\u4e8e\u6bcf\u5c40\u6e38\u620f\uff0c\u8f93\u51fa\u4e00\u884c\u3002\u5982\u679cdongdong \u5b58\u5728\u5fc5\u80dc\u7b56\u7565\u5219\u8f93\u51fa\u201c- -\u201d(\u4e0d\u542b \u5f15\u53f7) \u5426\u5219\u8f93\u51fa\u201c= =\u201d(\u4e0d\u542b\u5f15\u53f7)\u3002(\u6ce8\u610f\u8f93\u51fa\u7684\u90fd\u662f\u534a\u89d2\u7b26\u53f7\uff0c\u5373\u4e09\u4e2a\u7b26\u53f7 [&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\/350"}],"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=350"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}