{"id":101,"date":"2026-08-30T20:41:36","date_gmt":"2026-08-30T12:41:36","guid":{"rendered":"https:\/\/done.baka233.top\/?p=101"},"modified":"2026-10-01T09:20:35","modified_gmt":"2026-10-01T01:20:35","slug":"8-30-%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/done.baka233.top\/index.php\/2026\/08\/30\/8-30-%e6%97%a5%e5%bf%97\/","title":{"rendered":"8.30 \u65e5\u5fd7"},"content":{"rendered":"<h3>\u9898\u76ee &#8211; <a href=\"https:\/\/www.luogu.com.cn\/problem\/P1139\">luoguP1139<\/a><\/h3>\n<p>\u8003\u8651\u66b4\u641c\uff0c\u4e0d\u505c\u5c1d\u8bd5A\u5230B\u3001A\u5230C\u3001A\u5230D\u3001B\u5230C\u3001B\u5230D\u3001C\u5230D\uff0c\u5c1d\u8bd5\u987a\u5e8f\u6b63\u597d\u662f\u6309\u7167\u5b57\u5178\u5e8f\u3002\u4f46\u66b4\u641c\u4f1a\u70b8\uff0c\u53d1\u73b0\u603b\u7684\u64cd\u4f5c\u6b21\u6570\u6700\u5c11\u4e3a$n$\uff08\u6bcf\u8f86\u706b\u8f66\u76f4\u63a5A\u5230D\uff09\uff0c\u6700\u591a\u4e3a$3n$\uff08\u6bcf\u8f86\u706b\u8f66\u90fdA\u5230B\u3001B\u5230C\u3001C\u5230D\uff09\uff0c\u4e8e\u662f\u7c7b\u4f3c\u8fed\u4ee3\u52a0\u6df1\u641c\u7d22\u5730\u53bb\u9650\u5236\u603b\u7684\u64cd\u4f5c\u6b21\u6570\u8fdb\u884c\u641c\u7d22\uff0c\u9047\u5230\u53ef\u884c\u7684\u65b9\u6848\u5c31\u8f93\u51fa\u7b54\u6848\u540e\u5f3a\u5236exit\u3002\u8fd8\u8981\u52a0\u4e00\u4e9b\u53ef\u884c\u6027\u526a\u679d\uff0c\u4e0d\u7136\u4f1aTLE\u3002<\/p>\n<pre><code class=\"\" data-line=\"\">void dfs(int k, int m){\n\tif(k &gt; m){\n\t\tif(cnt[3] &lt; n) return ; \/\/ \u5df2\u7ecf\u64cd\u4f5c\u4e86m\u6b21\u5374\u8fd8\u6ca1\u8c03\u5ea6\u5b8c\n\t\tfor(auto v : ans){\n\t\t\tcout &lt;&lt; (char)(v.h + &#039;a&#039;) &lt;&lt; &#039; &#039;;\n\t\t\tcout &lt;&lt; (char)(v.l + &#039;A&#039;) &lt;&lt; &#039; &#039;;\n\t\t\tcout &lt;&lt; (char)(v.r + &#039;A&#039;) &lt;&lt; &#039;\\n&#039;;\n\t\t}\n\t\texit(0); \/\/ \u5f3a\u5236exit\n\t}\n\tif(cnt[3] &amp;&amp; a[3][cnt[3]] != s[n - cnt[3]] - &#039;a&#039;) return ; \/\/ D\u5904\u987a\u5e8f\u6709\u786c\u6027\u8981\u6c42\uff0c\u4e00\u5904\u4e0d\u5bf9\u5c31\u526a\u6389\n\tif(m - k + 1 &lt; cnt[0] + cnt[1] + cnt[2]) return ; \/\/ \u5269\u4e0b\u7684\u5373\u4f7f\u90fd\u76f4\u63a5\u5411D\u5904\u79fb\uff0c\u5269\u4f59\u64cd\u4f5c\u6b21\u6570\u4e5f\u4e0d\u591f\u4e86\n\tfor(int i = 0; i &lt;= 2; i++){ \/\/ 0-A, 1-B, 2-C\n\t\tif(!cnt[i]) continue; \/\/ i\u5904\u6ca1\u6709\u706b\u8f66\uff0c\u4e5f\u5c31\u4e0d\u7528\u8c03\u5ea6\n\t\tfor(int j = i + 1; j &lt;= 3; j++){ \/\/ \u53ea\u80fd\u4ece\u5de6\u5411\u53f3\u5355\u5411\u5f00\n\t\t\ta[j][++cnt[j]] = a[i][cnt[i]--]; \/\/ i -&gt; j\n\t\t\tans.push_back({a[j][cnt[j]], i, j}); \/\/ \u5b58\u64cd\u4f5c\n\t\t\tdfs(k + 1, m);\n\t\t\ta[i][++cnt[i]] = a[j][cnt[j]--]; \/\/ j -&gt; i \u56de\u6eaf\n\t\t\tans.pop_back(); \/\/ \u56de\u6eaf\u64cd\u4f5c\n\t\t}\n\t}\n}\nint main(){\n\tcin &gt;&gt; n &gt;&gt; s;\n\tfor(int i = 0; i &lt; n; i++) a[0][++cnt[0]] = i; \/\/ \u4e00\u5f00\u59cbA-0\u5904\u6709\u706b\u8f66a-0, b-1, c-2...\n\tfor(int i = n; i &lt;= 3 * n; i++) dfs(1, i);\n\tcout &lt;&lt; &quot;NO\\n&quot;; \/\/ \u6ca1\u6709\u65b9\u6848\n\treturn 0;\n}<\/code><\/pre>\n<h3>\u540e\u8bdd<\/h3>\n<p>\u8fed\u4ee3\u52a0\u6df1\u641c\u7d22 + \u53ef\u884c\u6027\u526a\u679d\uff0c\u63d0\u9ad8\u7ec4\u7ea7\u522b\u7684dfs\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee &#8211; luoguP1139 \u8003\u8651\u66b4\u641c\uff0c\u4e0d\u505c\u5c1d\u8bd5A\u5230B\u3001A\u5230C\u3001A\u5230D\u3001B\u5230C\u3001B\u5230D\u3001C\u5230D\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":0,"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"wp:attachment":[{"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/done.baka233.top\/index.php\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}