{"id":227,"date":"2026-07-27T00:05:21","date_gmt":"2026-07-26T16:05:21","guid":{"rendered":"https:\/\/huxiaole.cloud\/?p=227"},"modified":"2026-07-27T00:09:41","modified_gmt":"2026-07-26T16:09:41","slug":"p2148-sdoi2009-ed","status":"publish","type":"post","link":"https:\/\/huxiaole.cloud\/index.php\/2026\/07\/27\/p2148-sdoi2009-ed\/","title":{"rendered":"P2148 [SDOI2009] E&amp;D"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">P2148 [SDOI2009] E&amp;D<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c0f E \u4e0e\u5c0f W \u8fdb\u884c\u4e00\u9879\u540d\u4e3a <code>E&amp;D<\/code> \u6e38\u620f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6e38\u620f\u7684\u89c4\u5219\u5982\u4e0b\uff1a\u684c\u5b50\u4e0a\u6709 2n \u5806\u77f3\u5b50\uff0c\u7f16\u53f7\u4e3a $1 \\sim 2n$\u3002\u5176\u4e2d\uff0c\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u6211\u4eec\u5c06\u7b2c $2k-1$ \u5806\u4e0e\u7b2c $2k$ \u5806$\uff081 \\le k \\le n\uff09$\u89c6\u4e3a\u540c\u4e00\u7ec4\u3002\u7b2c $i$ \u5806\u7684\u77f3\u5b50\u4e2a\u6570\u7528\u4e00\u4e2a\u6b63\u6574\u6570 $S_i$ \u8868\u793a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u6b21\u5206\u5272\u64cd\u4f5c\u6307\u7684\u662f\uff0c\u4ece\u684c\u5b50\u4e0a\u4efb\u53d6\u4e00\u5806\u77f3\u5b50\uff0c\u5c06\u5176\u79fb\u8d70\u3002\u7136\u540e\u5206\u5272\u5b83\u540c\u4e00\u7ec4\u7684\u53e6\u4e00\u5806\u77f3\u5b50\uff0c\u4ece\u4e2d\u53d6\u51fa\u82e5\u5e72\u4e2a\u77f3\u5b50\u653e\u5728\u88ab\u79fb\u8d70\u7684\u4f4d\u7f6e\uff0c\u7ec4\u6210\u65b0\u7684\u4e00\u5806\u3002\u64cd\u4f5c\u5b8c\u6210\u540e\uff0c\u6240\u6709\u5806\u7684\u77f3\u5b50\u6570\u5fc5\u987b\u4fdd\u8bc1\u5927\u4e8e 0\u3002\u663e\u7136\uff0c\u88ab\u5206\u5272\u7684\u4e00\u5806\u7684\u77f3\u5b50\u6570\u81f3\u5c11\u8981\u4e3a 2\u3002\u4e24\u4e2a\u4eba\u8f6e\u6d41\u8fdb\u884c\u5206\u5272\u64cd\u4f5c\u3002\u5982\u679c\u8f6e\u5230\u67d0\u4eba\u8fdb\u884c\u64cd\u4f5c\u65f6\uff0c\u6240\u6709\u5806\u7684\u77f3\u5b50\u6570\u5747\u4e3a 1\uff0c\u5219\u6b64\u65f6\u6ca1\u6709\u77f3\u5b50\u53ef\u4ee5\u64cd\u4f5c\uff0c\u5224\u6b64\u4eba\u8f93\u6389\u6bd4\u8d5b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c0f E \u8fdb\u884c\u7b2c\u4e00\u6b21\u5206\u5272\u3002\u4ed6\u60f3\u77e5\u9053\uff0c\u662f\u5426\u5b58\u5728\u67d0\u79cd\u7b56\u7565\u4f7f\u5f97\u4ed6\u4e00\u5b9a\u80fd\u6218\u80dc\u5c0f W\u3002\u56e0\u6b64\uff0c\u4ed6\u6c42\u52a9\u4e8e\u5c0f F\uff0c\u4e5f\u5c31\u662f\u4f60\uff0c\u8bf7\u4f60\u544a\u8bc9\u4ed6\u662f\u5426\u5b58\u5728\u5fc5\u80dc\u7b56\u7565\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u521d\u59cb\u65f6\u684c\u5b50\u4e0a\u6709 4 \u5806\u77f3\u5b50\uff0c\u6570\u91cf\u5206\u522b\u4e3a ${1,2,3,1}$\u3002\u5c0f E \u53ef\u4ee5\u9009\u62e9\u79fb\u8d70\u7b2c 1 \u5806\uff0c\u7136\u540e\u5c06\u7b2c 2 \u5806\u5206\u5272\uff08\u53ea\u80fd\u5206\u51fa 1 \u4e2a\u77f3\u5b50\uff09\u3002\u63a5\u4e0b\u6765\uff0c\u5c0f W \u53ea\u80fd\u9009\u62e9\u79fb\u8d70\u7b2c 4 \u5806\uff0c\u7136\u540e\u5c06\u7b2c 3 \u5806\u5206\u5272\u4e3a 1 \u548c 2\u3002\u6700\u540e\u8f6e\u5230\u5c0f E\uff0c\u4ed6\u53ea\u80fd\u79fb\u8d70\u540e\u4e24\u5806\u4e2d\u6570\u91cf\u4e3a 1 \u7684\u4e00\u5806\uff0c\u5c06\u53e6\u4e00\u5806\u5206\u5272\u4e3a 1 \u548c 1\u3002\u8fd9\u6837\uff0c\u8f6e\u5230\u5c0f W \u65f6\uff0c\u6240\u6709\u5806\u7684\u6570\u91cf\u5747\u4e3a 1\uff0c\u5219\u4ed6\u8f93\u6389\u4e86\u6bd4\u8d5b\u3002\u6545\u5c0f E \u5b58\u5728\u5fc5\u80dc\u7b56\u7565\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u683c\u5f0f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u672c\u9898\u6709\u591a\u7ec4\u6570\u636e\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u884c\u4e00\u4e2a\u6574\u6570 T\uff0c\u8868\u793a\u6570\u636e\u7ec4\u6570\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u6bcf\u7ec4\u6570\u636e\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u884c\u4e00\u4e2a\u6574\u6570 N\uff0c\u8868\u793a\u684c\u5b50\u4e0a\u5171\u6709 N \u5806\u77f3\u5b50\uff0c\u8fd9\u91cc\u7684 N \u5373\u4e3a\u9898\u76ee\u63cf\u8ff0\u4e2d\u7684 $2n$\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u884c N \u4e2a\u6574\u6570 $S_{1 \\dots N}$\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u51fa\u683c\u5f0f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u6bcf\u7ec4\u6570\u636e\uff0c\u5982\u679c\u5c0f E \u5fc5\u80dc\uff0c\u5219\u4e00\u884c\u4e00\u4e2a\u5b57\u7b26\u4e32 <code>YES<\/code>\uff0c\u5426\u5219\u4e00\u884c\u4e00\u4e2a\u5b57\u7b26\u4e32 <code>NO<\/code>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #1<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165 #1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>2\n4\n1 2 3 1\n6\n1 1 1 1 1 1\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa #1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>YES\nNO\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bf4\u660e\/\u63d0\u793a<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e $20\\%$ \u7684\u6570\u636e\uff0c$N=2$\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u53e6\u5916 $20\\%$ \u7684\u6570\u636e\uff0c$N \\le 4\uff0cS_i \\le 50$\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e $100\\%$ \u7684\u6570\u636e\uff0c$1 \\le T \\le 20$\uff0c$1 \\le N \\le 2 \\times 10^4$ \u4e14 $N$ \u4e3a\u5076\u6570\uff0c$1 \\le S_i \\le 2 \\times 10^9$\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">sg\u51fd\u6570\uff0c\u6bcf\u4e2asg\u8868\u793a\u4e00\u79cd\u60c5\u51b5\uff0c\uff0c\u5e76\u7531\u591a\u79cd\u535a\u5f08\uff0c\u5f97\u51fa\u6700\u7ec8\u535a\u5f08\u7684\u7ed3\u8bba\uff0c\u80fd\u60f3\u5230\u7528sg\u51fd\u6570\u662f\u56e0\u4e3a\u5c06\u7b2c&nbsp;2k\u22121&nbsp;\u5806\u4e0e\u7b2c&nbsp;2k&nbsp;\u5806\uff081\u2264k\u2264n\uff09$\u89c6\u4e3a\u540c\u4e00\u7ec4\uff0c\u4e22\u5f03\u4e00\u5806\uff0c\u5206\u5f00\u4e00\u7ec4\u5806\uff0c\u591a\u7ec4\u7684\u60c5\u51b5\u5f97\u51fa\u6700\u7ec8\u7ed3\u8bba\u3002<br>\u4f46\u662f\u6211\u4eec\u4e0d\u77e5\u9053\u4ed6\u6709\u4ec0\u4e48\u89c4\u5f8b<br>\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6253\u8868\u5f97\u51fa\u7ed3\u8bba\uff0c\u6211\u4eec\u5df2\u77e5sg(1,1)\u60c5\u51b5\u4e3a0\uff0c\u7136\u540e\u6bcf\u79cd\u60c5\u51b5\u53ef\u4ee5\u8f6c\u6362\u6210\u4e4b\u524d\u7684\u60c5\u51b5\uff08\u5982\u60c5\u51b52\uff0c\u53ef\u4ee5\u75310\uff0c1\u8f6c\u6362\u800c\u6765\uff09<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6253\u8868\u601d\u8def<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bbe\u4e00\u7ec4\u4e24\u5806\u77f3\u5b50\u7684\u6570\u91cf\u4e3a(x,y)\u3002<br>\u6bcf\u6b21\u64cd\u4f5c\u53ea\u4f1a\u6539\u53d8\u5176\u4e2d\u4e00\u7ec4\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u7ec4\uff0c\u56e0\u6b64\u6bcf\u4e00\u7ec4\u90fd\u662f\u4e00\u4e2a\u72ec\u7acb\u5b50\u6e38\u620f\u3002\u6839\u636e SG \u5b9a\u7406\uff0c\u6700\u7ec8\u5c40\u9762\u7684 SG \u503c\u7b49\u4e8e\u6240\u6709\u5b50\u6e38\u620f SG \u503c\u7684\u5f02\u6216\u548c\u3002<br>\u5bf9\u4e8e\u72b6\u6001 (x,y)(x,y)(x,y)\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u79fb\u8d70 y\uff0c\u5c06 x \u5206\u6210 k \u548c x-k\uff0c\u53ef\u4ee5\u8f6c\u79fb\u5230 (k,x\u2212k)\uff1b<\/li>\n\n\n\n<li>\u79fb\u8d70 x\uff0c\u5c06 y \u5206\u6210 k \u548c y\u2212k\uff0c\u53ef\u4ee5\u8f6c\u79fb\u5230 (k,y\u2212k)\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>int dp&#91;MAXN]&#91;MAXN];\nint get_sg(int x,int y){\n\tif(dp&#91;x]&#91;y]!=-1)return dp&#91;x]&#91;y];\n\n\tset&lt;int&gt; se;\n\tfor(int k=1;k&lt;x;k++) se.insert(get_sg(k,x-k));\n\tfor(int k=1;k&lt;y;k++) se.insert(get_sg(k,y-k));\n\t\n\tint res=0;\n\twhile(se.count(res)) res++;\n\treturn dp&#91;x]&#91;y]=dp&#91;y]&#91;x]=res;\n}\n\n\n\tmemset(dp, -1, sizeof(dp));\n\tfor(int i=1;i&lt;=16;i++){\n\t\tfor(int j=1;j&lt;=16;j++){\n\t\t\tcout&lt;&lt;\"x:\"&lt;&lt;i&lt;&lt;\" y:\"&lt;&lt;j&lt;&lt;\" sg:\"&lt;&lt;get_sg(i,j)&lt;&lt;endl;\n\t\t}\n\t\tcout&lt;&lt;endl;\n\t}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u89c2\u5bdf\u5230<br>                                                $z=(x-1)|(y-1)$<br>\u7136\u540e\u7edf\u8ba1z\u7684\u6700\u4f4e\u4f4d\u8fde\u7eed1\u7684\u4e2a\u6570\uff0c\u5373\u4e3asg<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2aget_sg\u5feb\u901f\u5f97\u5230\u8fd9\u4e00\u7ec4\u7684sg\uff0c\u7136\u540e\u628a\u6240\u6709\u7ed3\u679c\u5f02\u6216\u5c31\u884c\u4e86<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Sunshine sunshine ladybugs awake,\n\/\/Clap your hooves and do a little shack.\n#include&lt;bits\/stdc++.h&gt;\n#define int long long\n#define endl \"\\n\"\n\nusing namespace std;\n\nusing PII=pair&lt;int,int&gt; ;\nconst int MAXN=50;\nconst int mod=998244353;\nconst int INF=0x3f3f3f3f3f3f3f3f;\n\nvoid solve(){\n\tauto get_sg=&#91;&amp;](int x,int y)-&gt;int{\n\t\tint z=(x-1)|(y-1);\n\t\tint sg=0;\n\t\twhile(z&amp;1){\n\t\t\tsg++;\n\t\t\tz&gt;&gt;=1;\n\t\t}\n\t\treturn sg;\n\t};\n\t\n\tint n;cin&gt;&gt;n;\n\tint ans=0;\n\tvector&lt;int&gt; a(n);\n\tfor(auto &amp;x:a)cin&gt;&gt;x;\n\tfor(int i=0;i&lt;n;i+=2){\n\t\tans^=get_sg(a&#91;i],a&#91;i+1]);\n\t}\n\t\n\tcout&lt;&lt;(ans?\"YES\":\"NO\")&lt;&lt;endl;\n}\n\nsigned main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tint t;cin&gt;&gt;t;while(t--)\n\tsolve();\n\treturn 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>P2148 [SDOI2009] E&amp;D \u9898\u76ee\u63cf\u8ff0 \u5c0f E \u4e0e\u5c0f W \u8fdb\u884c\u4e00\u9879\u540d\u4e3a E&amp;D \u6e38 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,16,18],"tags":[],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-dp","category-16","category-luogu"],"_links":{"self":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=227"}],"version-history":[{"count":5,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":234,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/227\/revisions\/234"}],"wp:attachment":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}