{"id":238,"date":"2026-07-29T00:05:08","date_gmt":"2026-07-28T16:05:08","guid":{"rendered":"https:\/\/huxiaole.cloud\/?p=238"},"modified":"2026-07-29T00:06:51","modified_gmt":"2026-07-28T16:06:51","slug":"cf776d-the-door-problem","status":"publish","type":"post","link":"https:\/\/huxiaole.cloud\/index.php\/2026\/07\/29\/cf776d-the-door-problem\/","title":{"rendered":"CF776D The Door Problem"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">CF776D The Door Problem<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Moriarty \u628an\u4e2a\u4eba\u5206\u522b\u56f0\u5728\u9152\u5e97\u7684n\u4e2a\u4e0d\u540c\u623f\u95f4\u91cc\u3002\u4e00\u4e9b\u623f\u95f4\u7684\u95e8\u662f\u9501\u7740\u7684\uff0c\u53e6\u5916\u4e00\u4e9b\u662f\u5f00\u7740\u7684\u3002\u4f46\u662f\uff0c\u6709\u4e00\u4e2a\u6761\u4ef6\uff0c\u53ea\u6709\u5f53\u6240\u6709\u623f\u95f4\u7684\u95e8\u540c\u65f6\u90fd\u662f\u6253\u5f00\u7684\u65f6\u5019\uff0c\u8fd9\u4e9b\u4eba\u624d\u80fd\u9003\u8131\u3002\u9152\u5e97\u91cc\u6709m\u4e2a\u5f00\u5173\u3002\u6bcf\u4e2a\u5f00\u5173\u53ef\u4ee5\u63a7\u5236\u4e00\u4e9b\u623f\u95f4\u7684\u95e8\uff0c\u4f46\u6bcf\u6247\u95e8\u6070\u597d\u88ab\u4e24\u4e2a\u5f00\u5173\u63a7\u5236\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u5f97\u5230\u4e86\u95e8\u7684\u521d\u59cb\u72b6\u6001\u3002\u6bcf\u5f53\u4f60\u5207\u6362\u4e00\u4e2a\u5f00\u5173\u65f6\uff08\u5373\u6253\u5f00\u53d8\u5173\u95ed\uff0c\u6216\u5173\u95ed\u53d8\u6253\u5f00\uff09\uff0c\u8be5\u5f00\u5173\u6240\u63a7\u5236\u7684\u6240\u6709\u623f\u95e8\u7684\u72b6\u6001\u90fd\u4f1a\u53d1\u751f\u6539\u53d8\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u4f60\u5207\u6362\u4e86\u5f00\u51731\uff0c\u5b83\u8fde\u63a5\u7684\u5206\u522b\u4e3a\u623f\u95f41\u30012\u548c3\uff0c\u8fd9\u4e9b\u623f\u95f4\u95e8\u5f53\u524d\u5206\u522b\u4e3a\u9501\u7740\u3001\u5f00\u7740\u3001\u5f00\u7740\u3002\u90a3\u4e48\uff0c\u5207\u6362\u540e\uff0c\u8fd9\u4e09\u6247\u95e8\u4f1a\u5206\u522b\u53d8\u4e3a\uff1a\u5f00\u7740\u3001\u9501\u7740\u3001\u9501\u7740\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u9700\u8981\u544a\u8bc9 Sherlock\uff0c\u662f\u5426\u5b58\u5728\u4e00\u79cd\u5207\u6362\u5f00\u5173\u7684\u65b9\u5f0f\uff0c\u4f7f\u5f97\u6240\u6709\u95e8\u540c\u65f6\u90fd\u88ab\u6253\u5f00\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\">\u8f93\u5165\u7684\u7b2c\u4e00\u884c\u5305\u542b\u4e24\u4e2a\u6574\u6570n\u548cm$\uff082 \\le n \\le 10^{5}\uff0c2 \\le m \\le 10^{5}\uff09$\uff0c\u5206\u522b\u8868\u793a\u623f\u95f4\u6570\u548c\u5f00\u5173\u6570\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u884c\u5305\u542bn\u4e2a\u7528\u7a7a\u683c\u5206\u9694\u7684\u6574\u6570$r_{1}, r_{2}, &#8230;, r_{n}\uff080 \\le r_{i} \\le 1\uff09$\uff0c\u8868\u793a\u6bcf\u4e2a\u623f\u95f4\u95e8\u7684\u5f53\u524d\u72b6\u6001\u3002\u5982\u679c$r_{i}=0$\uff0c\u5219\u7b2ci\u4e2a\u623f\u95f4\u95e8\u662f\u9501\u7740\u7684\uff1b\u5426\u5219\u662f\u5f00\u7740\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u7684m\u884c\uff0c\u7b2ci\u884c\u5305\u542b\u4e00\u4e2a\u6574\u6570$x_{i}\uff080 \\le x_{i} \\le n\uff09$\uff0c\u63a5\u7740\u662f$x_{i}$\u4e2a\u4e0d\u91cd\u590d\u7684\u6574\u6570\uff0c\u5206\u522b\u8868\u793a\u7b2ci\u4e2a\u5f00\u5173\u63a7\u5236\u7684\u623f\u95f4\u6570\u91cf\u4ee5\u53ca\u5404\u4e2a\u88ab\u63a7\u5236\u7684\u623f\u95f4\u7f16\u53f7\u3002\u4fdd\u8bc1\u623f\u95f4\u7f16\u53f7\u8303\u56f4\u57281\u5230n\u4e4b\u95f4\u3002\u4fdd\u8bc1\u6bcf\u6247\u95e8\u6070\u597d\u88ab\u4e24\u4e2a\u4e0d\u540c\u7684\u5f00\u5173\u63a7\u5236\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\">\u5982\u679c\u5b58\u5728\u4e00\u79cd\u5207\u6362\u5f00\u5173\u7684\u65b9\u5f0f\u53ef\u4ee5\u540c\u65f6\u6253\u5f00\u6240\u6709\u623f\u95e8\uff0c\u5219\u8f93\u51fa &#8220;YES&#8221;\uff08\u4e0d\u542b\u5f15\u53f7\uff09\uff0c\u5426\u5219\u8f93\u51fa &#8220;NO&#8221;\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>3 3\n1 0 1\n2 1 3\n2 1 2\n2 2 3\n\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>NO\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #2<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165 #2<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>3 3\n1 0 1\n3 1 2 3\n1 2\n2 1 3\n\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa #2<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>YES\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #3<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165 #3<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>3 3\n1 0 1\n3 1 2 3\n2 1 2\n1 3\n\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa #3<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>NO\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\">\u5728\u7b2c\u4e8c\u4e2a\u8f93\u5165\u6837\u4f8b\u4e2d\uff0c\u5404\u623f\u95e8\u521d\u59cb\u72b6\u6001\u4e3a[1,0,1]\uff080\u8868\u793a\u9501\u7740\uff0c1\u8868\u793a\u5f00\u7740\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u6b21\u5207\u6362\u7b2c3\u4e2a\u5f00\u5173\u540e\uff0c\u72b6\u6001\u53d8\u4e3a[0,0,0]\uff0c\u8868\u793a\u6240\u6709\u95e8\u90fd\u88ab\u9501\u4f4f\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u518d\u5207\u6362\u7b2c1\u4e2a\u5f00\u5173\uff0c\u72b6\u6001\u53d8\u4e3a[1,1,1]\uff0c\u5373\u6240\u6709\u623f\u95e8\u90fd\u6253\u5f00\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u53d1\u73b0\uff0c\u5bf9\u4e8e\u7b2c\u4e00\u4e2a\u548c\u7b2c\u4e09\u4e2a\u6837\u4f8b\u8f93\u5165\uff0c\u90fd\u4e0d\u5b58\u5728\u4f7f\u6240\u6709\u95e8\u90fd\u6253\u5f00\u7684\u5207\u6362\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531 ChatGPT 5 \u7ffb\u8bd1<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\u5230\u6bcf\u4e2a\u95e8\u53ea\u80fd\u6709\u4e24\u4e2a\u5f00\u5173\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5c06\u6bcf\u4e2a\u95e8\u5b58\u50a8\u7740\u54ea\u4e9b\u5f00\u5173\u5b58\u50a8\u4e00\u4e0b\u5047\u8bbe\u7b2c <code>i<\/code> \u6247\u95e8\u7531\u5f00\u5173 <code>a\u3001b<\/code> \u63a7\u5236\uff0c\u90a3\u4e48\u6700\u7ec8\u72b6\u6001\u4e3a\uff1a<br>$r_i\u200b\u2295x_a\u200b\u2295x_b\u200b$<br>\u6211\u4eec\u8981\u6c42\u6700\u7ec8\u72b6\u6001\u4e3a<code>1<\/code>\uff1a<br>$r_i\u2295x_a\u2295x_b=1$<br>\u79fb\u9879\u5f97\u5230\uff1a<br>$x_a\u2295x_b=1\u2212r_i$<br>\u56e0\u6b64\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f53 $r_i=1$ \u65f6\uff0c$x_a=x_b\u200b$\uff0c\u4e24\u4e2a\u5f00\u5173\u72b6\u6001\u76f8\u540c\u3002<\/li>\n\n\n\n<li>\u5f53 $r_i=0$ \u65f6\uff0c$x_a\u2260x_b$\u200b\uff0c\u4e24\u4e2a\u5f00\u5173\u72b6\u6001\u4e0d\u540c\u3002<br>\u4ee4\u8fb9\u6743\uff1a<br>$w=1\u2212r_i\u200b$<br>\u90a3\u4e48\u6bcf\u6761\u8fb9\u90fd\u8981\u6c42\uff1a<br>$color[a]\u2295color[b]=w$<br>color\u8bb0\u5f55\u6bcf\u4e2a\u8282\u70b9\u7684\u989c\u8272\uff0c\u5982\u679c\u8fd9\u4e2a\u8282\u70b9\u5df2\u7ecf\u67d3\u8272\u8bf4\u660e\u4ed6\u5df2\u7ecf\u88ab\u8bbf\u95ee\u8fc7\u4e86\uff0c\u5982\u679c\u8fd9\u4e2a\u8282\u70b9\u8fd8\u6ca1\u6709\u67d3\u8272\uff0c\u90a3\u4e48\u628a\u8fd9\u4e2a\u8282\u70b9\u89c6\u4e3a\u65b0\u7684\u8fde\u901a\u5757\u7684\u8d77\u70b9\uff0c\u5e76\u7ed9\u4e00\u4e2a\u989c\u8272\uff0c\u90a3\u4e48\u5176\u4ed6\u4fee\u6539\u540e\u7684\u8282\u70b9\u989c\u8272\u5e94\u8be5\u6ee1\u8db3\u8fb9\u4e0a\u7684\u201c\u76f8\u540c\u6216\u4e0d\u540c\u201d\u7ea6\u675f\uff0c\u5982\u679c\u4e0d\u4e00\u81f4\u5c31\u662fNO\uff0c\u5982\u679c\u90fd\u7b26\u5408\u5c31\u662fYES<\/li>\n<\/ul>\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>\n#define int long long\n#define endl \"\\n\"\n\nusing namespace std;\n\nusing PII=pair&lt;int,int> ;\nconst int MAXN=300005;\nconst int mod=998244353;\nconst int INF=0x3f3f3f3f3f3f3f3f;\n\nvoid solve(){\n\tint n,m;\n\tcin>>n>>m;\n\tvector&lt;int> r(n+1);\n\tfor(int i=1;i&lt;=n;i++)cin>>r&#91;i];\n\t\n\tvector&lt;vector&lt;int>> controlledBy(n+1);\n\t\n\tfor(int i=1;i&lt;=m;i++){\n\t\tint q;cin>>q;\n\t\twhile(q--){\n\t\t\tint x;cin>>x;\n\t\t\tcontrolledBy&#91;x].push_back(i);\n\t\t}\n\t}\n\t\n\tvector&lt;vector&lt;PII>> graph(m+1);\n\tfor(int i=1;i&lt;=n;i++){\n        int a=controlledBy&#91;i]&#91;0];\n        int b=controlledBy&#91;i]&#91;1];\n\n        int w=1-r&#91;i];\n\n        graph&#91;a].push_back({b,w});\n        graph&#91;b].push_back({a,w});\n    }\n\t\n\tvector&lt;int> color(m+1,-1);\n\tfor(int start=1;start&lt;=m;start++){\n\t\tif(color&#91;start]!=-1){\n\t\t\tcontinue;\n\t\t}\n\n\t\tcolor&#91;start]=0;\n\n\t\tqueue&lt;int> q;\n\t\tq.push(start);\n\n\t\twhile(!q.empty()){\n\t\t\tint u=q.front();\n\t\t\tq.pop();\n\n\t\t\tfor(auto &#91;v,w]:graph&#91;u]){\n\t\t\t\tint expected_color=color&#91;u]^w;\n\n\t\t\t\tif(color&#91;v]==-1){\n\t\t\t\t\tcolor&#91;v]=expected_color;\n\t\t\t\t\tq.push(v);\n\t\t\t\t}else if(color&#91;v]!=expected_color){\n\t\t\t\t\tcout&lt;&lt;\"NO\"&lt;&lt;endl;\n\t\t\t\t\treturn ;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcout&lt;&lt;\"YES\"&lt;&lt;endl;\n}\n\nsigned main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\t\/\/int t;cin>>t;while(t--)\n\tsolve();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CF776D The Door Problem \u9898\u76ee\u63cf\u8ff0 Moriarty \u628an\u4e2a\u4eba\u5206\u522b\u56f0\u5728\u9152\u5e97\u7684n\u4e2a\u4e0d\u540c\u623f\u95f4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,12],"tags":[],"class_list":["post-238","post","type-post","status-publish","format-standard","hentry","category-codeforces","category-12"],"_links":{"self":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/238","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=238"}],"version-history":[{"count":3,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":242,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/238\/revisions\/242"}],"wp:attachment":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}