{"id":346,"date":"2010-08-16T01:13:00","date_gmt":"2010-08-15T17:13:00","guid":{"rendered":"http:\/\/localhost\/?p=346"},"modified":"2010-08-16T01:13:00","modified_gmt":"2010-08-15T17:13:00","slug":"poi2009prz","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=346","title":{"rendered":"[POI2009]Prz"},"content":{"rendered":"\n<p>[POI2009]Prz<\/p>\n<p>Time Limit:10000MS&#160; Memory Limit:165536K<br \/>Total Submit:16 Accepted:1 <br \/>Case Time Limit:1000MS<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> \u4f60\u7684\u4efb\u52a1\u662f\u8ba1\u7b97\u4e00\u4e2a\u51fd\u6570F(x, y)\uff0c\u5176\u4e2dx\u548cy\u662f\u4e24\u4e2a\u6b63\u6574\u6570\u5e8f\u5217\u3002F\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a <\/p>\n<p>boolean F(x, y) <\/p>\n<p>if W(x) \u2260 W(y) then return 0 <\/p>\n<p>else if |W(x)| = |W(y)| = 1 then return 1 <\/p>\n<p>else return F(p(x), p(y)) AND F(s(x), s(y)). <\/p>\n<p>W(x)\u8868\u793a\u5e8f\u5217x\u4e2d\u5143\u7d20\u7684\u96c6\u5408\u3002\uff08\u5143\u7d20\u7684\u987a\u5e8f\u548c\u51fa\u73b0\u6b21\u6570\u5c06\u88ab\u65e0\u89c6\uff09 <\/p>\n<p>p(x)\u8868\u793a\u5e8f\u5217x\u7684\u6700\u957f\u524d\u7f00\uff0c\u6ee1\u8db3\uff1aW(x) \u2260 W(p(x)) <\/p>\n<p>s(x)\u8868\u793a\u5e8f\u5217x\u7684\u6700\u957f\u540e\u7f00\u3002\u6ee1\u8db3\uff1aW(x) \u2260 W(s(x)) <\/p>\n<p>|Z|\u8868\u793a\u96c6\u5408Z\u4e2d\u5143\u7d20\u4e2a\u6570 <\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u7b2c\u4e00\u884ck\u8868\u793a\u6570\u636e\u7ec4\u6570\u3002 <br \/>\u5bf9\u4e8e\u6bcf\u7ec4\u6570\u636e\uff0c\u7b2c\u4e00\u884cn,m\u5206\u522b\u8868\u793ax\u5e8f\u5217\u7684\u957f\u5ea6\u4e0ey\u5e8f\u5217\u7684\u957f\u5ea6\uff0c\u7b2c\u4e8c\u884cn\u4e2a\u6570\u8868\u793axi\uff0c\u7b2c\u4e09\u884cm\u4e2a\u6570\u8868\u793ayi <br \/>1&lt;=k&lt;=13 <br \/>1&lt;=n,m&lt;=100000 <br \/>1&lt;=xi,yi&lt;=100 <\/p>\n<p><\/p>\n<p><strong>Output <\/strong><\/p>\n<p> k\u884c\uff0c\u5bf9\u4e8e\u6bcf\u7ec4\u6570\u636e\uff0c\u82e5F(x,y)\u4e3a\u771f\u8f93\u51fa1\uff0c\u5426\u5219\u8f93\u51fa0\u3002 <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>2<br \/>4 5<br \/>3 1 2 1<br \/>1 3 1 2 1<br \/>7 7<br \/>1 1 2 1 2 1 3<br \/>1 1 2 1 3 1 3<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>0<br \/>1<\/p>\n<p><strong>Hint <\/strong><\/p>\n<p> \u611f\u8c22MT\u5927\u725b\u8d21\u732e\u8bd1\u6587.<\/p>\n<p><strong>Source <\/strong><\/p>\n<p>\u8fd9\u4e2a\u9898\u3002\u3002\u3002\u3002\u989d\u3002\u3002\u975e\u5e38\u6076\u5fc3\u3002\u3002<br \/>\u9996\u5148\u627e\u89c4\u5f8b\u662f\u8981\u60b2\u5267\u7684\u56e7\u3002\u3002\u3002\u6211\u5f04\u4e86\u534a\u5929\u6beb\u65e0\u6210\u6548\u3002\u3002<br \/>\u7136\u540e\u60f3\u7684\u5c31\u662fDP\u3002\u3002\u3002\u3002<br \/>\u6bd4\u5982\u8bf4F(l1,r1,l2,r2)\u8868\u793aX\u7684l\u5230r\uff0cY\u7684l2\u5230r2\u662f\u5426\u5339\u914d\u3002\u3002<br \/>\u7136\u540ePrefix\u548cSuffix\u90fd\u53ef\u4ee5\u9884\u5904\u7406\u3002\u6240\u4ee5\u5c31\u662fN^4\u3002\u3002\u65e0\u538b\u529bTLE<br \/>\u7136\u540e\u6ce8\u610f\u5230\u4e24\u4e2a\u5b57\u4e32\u4e2d\u7684\u4e0d\u540c\u6570\u7684\u6570\u91cf\u80af\u5b9a\u662f\u4e00\u6837\u7684\u3002\u3002\/\/\u5c31\u662fW<br \/>\u7136\u540eF(l1,l2,num)\u8868\u793aX\u4ecel1\u5f00\u59cb\uff0cY\u4ecel2\u5f00\u59cb\u3002\u3002\u90fd\u662fnum\u4e2a\u4e0d\u540c\u7684\u5b57\u7b26\u3002\u3002\u662f\u5426\u5339\u914d\u3002\u3002\uff1f<br \/>\u8bbeK=100<br \/>N^2*K\u3002\u3002\u3002\u65e0\u538b\u529bTLE\u3002\u3002<br \/>\u7136\u540e\u6ce8\u610f\u5230\u8fd9\u4e2a\u662f\u68c0\u67e5\u662f\u5426\u76f8\u7b49\u3002\u3002\u6240\u4ee5\u53ef\u4ee5\u7528Hash\u3002\u3002<br \/>\u5c31\u662f\u628a\u5b83\u7684prefix\u548csuffix\u968f\u4fbfHash\u4e00\u4e0b\u3002\u3002\u7136\u540e\u4e24\u4e2a\u5224\u65adX\u548cY\u662f\u5426\u76f8\u7b49\u3002\u3002<br \/>\u8fd9\u6837\u7684\u8bdd\u8981\u8003\u8651\u5982\u4f55\u7b97Prefix\u3002\u3002\u5982\u679c\u9884\u5904\u7406\u6bcf\u4e2a\u4e00\u4f4d\u5230\u4e0b\u4e00\u4e2a\u6bcf\u79cd\u6570\u7684\u6700\u8fd1\u503c\uff08\u524d\u548c\u540e\uff09\u3002\u3002\uff1f<br \/>\u53ef\u4ee5\u5728O\uff08K\uff09\u7684\u65f6\u95f4\u641e\u5b9aPrefix\u548cSuffix\u3002\u3002<br \/>\u7136\u540e\u5c31\u53ef\u4ee5\u5728N*K^2\u7684\u65f6\u95f4\u641e\u5b9aHash\u3002\u3002\u3002<br \/>\u7136\u540e\u518d\u8003\u8651\u5982\u679c\u5bf9\u6bcf\u4e00\u4f4d\u7684\u4fe1\u606f\u8fdb\u884c\u6392\u5e8f\u3002\u3002<br \/>\u53ef\u4ee5\u505a\u5230O\uff08LogK\uff09\u7684\u65f6\u95f4\u641e\u5b9aPrefix\u548cSuffix\u3002\u3002\u5c31\u662fN*K*LogK<br \/>\u6211\u73b0\u5728\u5199\u7684\u5c31\u662f\u8fd9\u6837\u3002\u3002TLE\u7684\u975e\u5e38\u4e25\u91cd\u3002\u3002\u4f46\u662f\u6211\u53d1\u73b0\u6211\u5199\u7684\u8fd9\u6837\u8981\u6bd4<br \/>\u6807\u7a0b\u5feb\u5f88\u591a\u7011\u5e03\u6c57\u3002\u3002\u3002root\u7684\u65f6\u9650\u597d\u7d27\u554a\u56e7\u3002\u3002\u3002<br \/>\u7136\u540e\u63a5\u4e0b\u6765\u8fd8\u662f\u53ef\u4ee5\u4f18\u5316\u3002\u3002\u4e0d\u8fc7\u4e03\u5915\u8282\u5230\u4e86\u6709\u522b\u7684\u4e8b\u8981\u5fd9\u5c31\u5148\u4e0d\u5199\u4e86\u56e7\u3002\u3002\u3002\u3002<br \/>\u5982\u679c\u7528\u626b\u63cf\u7684\u529e\u6cd5\u53ef\u4ee5\u5728N*K\u7684\u65f6\u95f4\u5185\u7b97\u51fa\u6240\u6709Prefix\u548cSuffix\u3002\u3002\u7136\u540e<br \/>\u590d\u6742\u5ea6\u5c31\u662fN*K\u4e86\u3002\u3002\u5e94\u8be5\u53ef\u4ee5AC\u5427\u56e7\u3002\u3002\u3002<br \/>\u7ec8\u4e8eAC\u3002\u3002\u6cea\u6d41\u6ee1\u9762\u3002\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[POI2009]Prz Time Limit:10000MS&#160; Memory Limit:165536KTotal Submit:16 Accepted:1 Case Time Limit:1000MS Description \u4f60\u7684\u4efb\u52a1\u662f\u8ba1\u7b97\u4e00\u4e2a\u51fd\u6570F(x, y)\uff0c\u5176\u4e2dx\u548cy\u662f\u4e24\u4e2a\u6b63\u6574\u6570\u5e8f\u5217\u3002F\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a boolean F(x, y) if W(x) \u2260 W(y) then return 0 else if |W(x)| = |W(y)| = 1 then return 1 else return F(p(x), p(y)) AND F(s(x), s(y)). W(x)\u8868\u793a\u5e8f\u5217x\u4e2d\u5143\u7d20\u7684\u96c6\u5408\u3002\uff08\u5143\u7d20\u7684\u987a\u5e8f\u548c\u51fa\u73b0\u6b21\u6570\u5c06\u88ab\u65e0\u89c6\uff09 p(x)\u8868\u793a\u5e8f\u5217x\u7684\u6700\u957f\u524d\u7f00\uff0c\u6ee1\u8db3\uff1aW(x) \u2260 W(p(x)) s(x)\u8868\u793a\u5e8f\u5217x\u7684\u6700\u957f\u540e\u7f00\u3002\u6ee1\u8db3\uff1aW(x) \u2260 W(s(x)) |Z|\u8868\u793a\u96c6\u5408Z\u4e2d\u5143\u7d20\u4e2a\u6570 Input \u7b2c\u4e00\u884ck\u8868\u793a\u6570\u636e\u7ec4\u6570\u3002 \u5bf9\u4e8e\u6bcf\u7ec4\u6570\u636e\uff0c\u7b2c\u4e00\u884cn,m\u5206\u522b\u8868\u793ax\u5e8f\u5217\u7684\u957f\u5ea6\u4e0ey\u5e8f\u5217\u7684\u957f\u5ea6\uff0c\u7b2c\u4e8c\u884cn\u4e2a\u6570\u8868\u793axi\uff0c\u7b2c\u4e09\u884cm\u4e2a\u6570\u8868\u793ayi 1&lt;=k&lt;=13 1&lt;=n,m&lt;=100000 1&lt;=xi,yi&lt;=100 Output [&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\/346"}],"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=346"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/346\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}