{"id":588,"date":"2026-07-06T19:39:08","date_gmt":"2026-07-06T11:39:08","guid":{"rendered":"https:\/\/mitongxue.cn\/?p=588"},"modified":"2026-07-06T19:39:08","modified_gmt":"2026-07-06T11:39:08","slug":"hj27-%e6%9f%a5%e6%89%be%e5%85%84%e5%bc%9f%e5%8d%95%e8%af%8d","status":"publish","type":"post","link":"https:\/\/mitongxue.cn\/index.php\/2026\/07\/06\/hj27-%e6%9f%a5%e6%89%be%e5%85%84%e5%bc%9f%e5%8d%95%e8%af%8d\/","title":{"rendered":"HJ27\u00a0\u67e5\u627e\u5144\u5f1f\u5355\u8bcd"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u63cf\u8ff0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>s<\/mi><\/mrow><\/semantics><\/math><em>s<\/em>&nbsp;\u7684\u201c\u5144\u5f1f\u5355\u8bcd\u201d\u4e3a\uff1a\u5c06&nbsp;<math><semantics><mrow><mi>s<\/mi><\/mrow><\/semantics><\/math><em>s<\/em>&nbsp;\u91cd\u65b0\u6392\u5e8f\u540e\u5f97\u5230\u7684\u4e0e\u539f\u5b57\u7b26\u4e32\u4e0d\u540c\u7684\u65b0\u5b57\u7b26\u4e32\u3002<br><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u73b0\u5728\uff0c\u5bf9\u4e8e\u7ed9\u5b9a\u7684&nbsp;<math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em>&nbsp;\u4e2a\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><msub><mi>s<\/mi><mn>1<\/mn><\/msub><mo separator=\"true\">,<\/mo><msub><mi>s<\/mi><mn>2<\/mn><\/msub><mo separator=\"true\">,<\/mo><mo>\u2026<\/mo><mo separator=\"true\">,<\/mo><msub><mi>s<\/mi><mi>n<\/mi><\/msub><\/mrow><\/semantics><\/math><em>s<\/em>1\u200b,<em>s<\/em>2\u200b,\u2026,<em>s<\/em><em>n<\/em>\u200b&nbsp;\u548c\u53e6\u4e00\u4e2a\u5355\u72ec\u7684\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>x<\/mi><\/mrow><\/semantics><\/math><em>x<\/em>\uff0c\u4f60\u9700\u8981\u89e3\u51b3\u4e24\u4e2a\u95ee\u9898\uff1a<br><math><semantics><mrow><mspace width=\"2.3000000000000003em\"><\/mspace><mo>\u2219<\/mo><mtext>\u2009<\/mtext><\/mrow><\/semantics><\/math>\u2219\u7edf\u8ba1\u8fd9&nbsp;<math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em>&nbsp;\u4e2a\u5b57\u7b26\u4e32\u4e2d\uff0c\u6709\u591a\u5c11\u4e2a\u662f&nbsp;<math><semantics><mrow><mi>x<\/mi><\/mrow><\/semantics><\/math><em>x<\/em>&nbsp;\u7684\u201c\u5144\u5f1f\u5355\u8bcd\u201d\uff08\u6ce8\u610f\uff0c\u8fd9&nbsp;<math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em>&nbsp;\u4e2a\u5b57\u7b26\u4e32\u53ef\u80fd\u6709\u91cd\u590d\uff0c\u91cd\u590d\u5b57\u7b26\u4e32\u5206\u522b\u8ba1\u6570\uff09\uff1b<br><math><semantics><mrow><mspace width=\"2.3000000000000003em\"><\/mspace><mo>\u2219<\/mo><mtext>\u2009<\/mtext><\/mrow><\/semantics><\/math>\u2219\u5c06\u8fd9&nbsp;<math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em>&nbsp;\u4e2a\u5b57\u7b26\u4e32\u4e2d&nbsp;<math><semantics><mrow><mi>x<\/mi><\/mrow><\/semantics><\/math><em>x<\/em>&nbsp;\u7684\u201c\u5144\u5f1f\u5355\u8bcd\u201d\u6309\u5b57\u5178\u5e8f\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\uff0c\u8f93\u51fa\u6392\u5e8f\u540e\u7684\u7b2c&nbsp;<math><semantics><mrow><mi>k<\/mi><\/mrow><\/semantics><\/math><em>k<\/em>&nbsp;\u4e2a\u5144\u5f1f\u5355\u8bcd\uff08\u4ece&nbsp;<math><semantics><mrow><mn>1<\/mn><\/mrow><\/semantics><\/math>1&nbsp;\u5f00\u59cb\u8ba1\u6570\uff09\u3002\u7279\u522b\u5730\uff0c\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5219\u4e0d\u8f93\u51fa\u4efb\u4f55\u5185\u5bb9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u540d\u8bcd\u89e3\u91ca\u3011<br><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u4ece\u5b57\u7b26\u4e32\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u5f00\u59cb\u9010\u4e2a\u6bd4\u8f83\uff0c\u76f4\u81f3\u53d1\u73b0\u7b2c\u4e00\u4e2a\u4e0d\u540c\u7684\u4f4d\u7f6e\uff0c\u6bd4\u8f83\u8fd9\u4e2a\u4f4d\u7f6e\u5b57\u7b26\u7684\u5b57\u6bcd\u8868\u987a\u5e8f\uff0c\u5b57\u6bcd\u5e8f\u8f83\u5c0f\u7684\u5b57\u7b26\u4e32\u5b57\u5178\u5e8f\u4e5f\u8f83\u5c0f\uff1b\u5982\u679c\u6bd4\u8f83\u5230\u5176\u4e2d\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u65f6\u4f9d\u65e7\u5168\u90e8\u76f8\u540c\uff0c\u5219\u8f83\u77ed\u7684\u5b57\u7b26\u4e32\u5b57\u5178\u5e8f\u66f4\u5c0f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5728\u4e00\u884c\u4e0a\u4f9d\u6b21\u8f93\u5165\uff1a<br><math><semantics><mrow><mspace width=\"2.3000000000000003em\"><\/mspace><mo>\u2219<\/mo><mtext>\u2009<\/mtext><\/mrow><\/semantics><\/math>\u2219\u4e00\u4e2a\u6574\u6570&nbsp;<math><semantics><mrow><mi>n<\/mi><mrow><mo fence=\"true\">(<\/mo><mn>1<\/mn><mo>\u2266<\/mo><mi>n<\/mi><mo>\u2266<\/mo><mn>1<\/mn><msup><mn>0<\/mn><mn>3<\/mn><\/msup><mo fence=\"true\">)<\/mo><\/mrow><\/mrow><\/semantics><\/math><em>n<\/em>(1\u2266<em>n<\/em>\u2266103)&nbsp;\u4ee3\u8868\u5b57\u7b26\u4e32\u7684\u4e2a\u6570\uff1b<br><math><semantics><mrow><mspace width=\"2.3000000000000003em\"><\/mspace><mo>\u2219<\/mo><mtext>\u2009<\/mtext><\/mrow><\/semantics><\/math>\u2219<math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em>&nbsp;\u4e2a\u957f\u5ea6\u4e3a&nbsp;<math><semantics><mrow><mn>1<\/mn><mo>\u2266<\/mo><mrow><mi mathvariant=\"normal\">l<\/mi><mi mathvariant=\"normal\">e<\/mi><mi mathvariant=\"normal\">n<\/mi><mi mathvariant=\"normal\">g<\/mi><mi mathvariant=\"normal\">t<\/mi><mi mathvariant=\"normal\">h<\/mi><\/mrow><mo stretchy=\"false\">(<\/mo><msub><mi>s<\/mi><mi>i<\/mi><\/msub><mo stretchy=\"false\">)<\/mo><mo>\u2266<\/mo><mn>10<\/mn><\/mrow><\/semantics><\/math>1\u2266length(<em>s<\/em><em>i<\/em>\u200b)\u226610\uff0c\u4ec5\u7531\u5c0f\u5199\u5b57\u6bcd\u6784\u6210\u7684\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><msub><mi>s<\/mi><mn>1<\/mn><\/msub><mo separator=\"true\">,<\/mo><msub><mi>s<\/mi><mn>2<\/mn><\/msub><mo separator=\"true\">,<\/mo><mo>\u2026<\/mo><mo separator=\"true\">,<\/mo><msub><mi>s<\/mi><mi>n<\/mi><\/msub><\/mrow><\/semantics><\/math><em>s<\/em>1\u200b,<em>s<\/em>2\u200b,\u2026,<em>s<\/em><em>n<\/em>\u200b&nbsp;\uff1b<br><math><semantics><mrow><mspace width=\"2.3000000000000003em\"><\/mspace><mo>\u2219<\/mo><mtext>\u2009<\/mtext><\/mrow><\/semantics><\/math>\u2219\u4e00\u4e2a\u957f\u5ea6\u4e3a&nbsp;<math><semantics><mrow><mn>1<\/mn><mo>\u2266<\/mo><mrow><mi mathvariant=\"normal\">l<\/mi><mi mathvariant=\"normal\">e<\/mi><mi mathvariant=\"normal\">n<\/mi><mi mathvariant=\"normal\">g<\/mi><mi mathvariant=\"normal\">t<\/mi><mi mathvariant=\"normal\">h<\/mi><\/mrow><mo stretchy=\"false\">(<\/mo><mi>x<\/mi><mo stretchy=\"false\">)<\/mo><mo>\u2266<\/mo><mn>10<\/mn><\/mrow><\/semantics><\/math>1\u2266length(<em>x<\/em>)\u226610\uff0c\u4ec5\u7531\u5c0f\u5199\u5b57\u6bcd\u6784\u6210\u7684\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>x<\/mi><\/mrow><\/semantics><\/math><em>x<\/em>&nbsp;\uff1b<br><math><semantics><mrow><mspace width=\"2.3000000000000003em\"><\/mspace><mo>\u2219<\/mo><mtext>\u2009<\/mtext><\/mrow><\/semantics><\/math>\u2219\u4e00\u4e2a\u6574\u6570&nbsp;<math><semantics><mrow><mi>k<\/mi><mrow><mo fence=\"true\">(<\/mo><mn>1<\/mn><mo>\u2266<\/mo><mi>k<\/mi><mo>\u2266<\/mo><mi>n<\/mi><mo fence=\"true\">)<\/mo><\/mrow><\/mrow><\/semantics><\/math><em>k<\/em>(1\u2266<em>k<\/em>\u2266<em>n<\/em>)&nbsp;\u4ee3\u8868\u8981\u67e5\u627e\u7684\u7b2c&nbsp;<math><semantics><mrow><mi>k<\/mi><\/mrow><\/semantics><\/math><em>k<\/em>&nbsp;\u5c0f\u7684\u5144\u5f1f\u5355\u8bcd\u7684\u5e8f\u53f7\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u7b2c\u4e00\u884c\u8f93\u51fa\u4e00\u4e2a\u6574\u6570\uff0c\u4ee3\u8868\u7ed9\u5b9a\u7684&nbsp;<math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em>&nbsp;\u4e2a\u5b57\u7b26\u4e32\u4e2d\uff0c<math><semantics><mrow><mi>x<\/mi><\/mrow><\/semantics><\/math><em>x<\/em>&nbsp;\u7684\u201c\u5144\u5f1f\u5355\u8bcd\u201d\u7684\u6570\u91cf\uff1b<br><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u7b2c\u4e8c\u884c\u8f93\u51fa\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u4ee3\u8868\u5c06\u7ed9\u5b9a\u7684&nbsp;<math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em>&nbsp;\u4e2a\u5b57\u7b26\u4e32\u4e2d&nbsp;<math><semantics><mrow><mi>x<\/mi><\/mrow><\/semantics><\/math><em>x<\/em>&nbsp;\u7684\u201c\u5144\u5f1f\u5355\u8bcd\u201d\u6309\u5b57\u5178\u5e8f\u6392\u5e8f\u540e\u7684\u7b2c&nbsp;<math><semantics><mrow><mi>k<\/mi><\/mrow><\/semantics><\/math><em>k<\/em>&nbsp;\u5c0f\u5144\u5f1f\u5355\u8bcd\u3002\u7279\u522b\u5730\uff0c\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5219\u4e0d\u8f93\u51fa\u4efb\u4f55\u5185\u5bb9\uff08\u5b8c\u5168\u7701\u7565\u7b2c\u4e8c\u884c\uff09\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b1<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>3 abc bca cab abc 1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2\nbca<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u660e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5728\u8fd9\u4e2a\u6837\u4f8b\u4e2d\uff0c<math><semantics><mrow><mi>x<\/mi><\/mrow><\/semantics><\/math><em>x<\/em> \u7684\u5144\u5f1f\u5355\u8bcd\u4e3a <math><semantics><mrow><mtext mathvariant=\"monospace\">\"acb\"<\/mtext><\/mrow><\/semantics><\/math>\"acb\" \u3001<math><semantics><mrow><mtext mathvariant=\"monospace\">\"bac\"<\/mtext><\/mrow><\/semantics><\/math>\"bac\" \u3001<math><semantics><mrow><mtext mathvariant=\"monospace\">\"<\/mtext><mstyle mathcolor=\"orange\"><mtext mathvariant=\"monospace\">bca<\/mtext><\/mstyle><mtext mathvariant=\"monospace\">\"<\/mtext><\/mrow><\/semantics><\/math>\"bca\" \u3001<math><semantics><mrow><mtext mathvariant=\"monospace\">\"<\/mtext><mstyle mathcolor=\"orange\"><mtext mathvariant=\"monospace\">cab<\/mtext><\/mstyle><mtext mathvariant=\"monospace\">\"<\/mtext><\/mrow><\/semantics><\/math>\"cab\" \u3001<math><semantics><mrow><mtext mathvariant=\"monospace\">\"cba\"<\/mtext><\/mrow><\/semantics><\/math>\"cba\" \u3002\u5176\u4e2d\uff0c\u6807\u6a59\u8272\u7684\u4e24\u4e2a\u5b57\u7b26\u4e32\u5b58\u5728\u4e8e\u6240\u7ed9\u5b9a\u7684 <math><semantics><mrow><mi>n<\/mi><\/mrow><\/semantics><\/math><em>n<\/em> \u4e2a\u5b57\u7b26\u4e32\u4e2d\u3002\u7b2c <math><semantics><mrow><mn>1<\/mn><\/mrow><\/semantics><\/math>1 \u5c0f\u7684\u5144\u5f1f\u5355\u8bcd\u4e3a <math><semantics><mrow><mtext mathvariant=\"monospace\">\"bca\"<\/mtext><\/mrow><\/semantics><\/math>\"bca\"\u3002<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>3 a aa aaa a 1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u660e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5728\u8fd9\u4e2a\u6837\u4f8b\u4e2d\uff0c\u6309\u7167\u5b9a\u4e49\uff0c\u5b57\u7b26\u4e32 <math><semantics><mrow><mtext mathvariant=\"monospace\">\"a\"<\/mtext><\/mrow><\/semantics><\/math>\"a\" \u6ca1\u6709\u5144\u5f1f\u5355\u8bcd\u3002<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5224\u65ad\u5144\u5f1f\u5355\u8bcd\u6280\u5de7:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u91c7\u7528\u6c42\u5b50\u4e32\u7684\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b57\u7b26\u4e32\u5bf9\u6bd4\u7684\u65b9\u5f0f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">box[i].split(&#8220;&#8221;).sort().join(&#8220;&#8221;)===target &amp;&amp; box[i]!==target<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nvoid async function () {\n    \/\/ Write your code here\n    while(line = await readline()){\n        let tokens = line.split(' ');\n        const num = tokens&#91;0]*1;\n        const box = tokens.slice(1,num+1);\n        const target = tokens&#91;num+1];\n        const kIdx =  tokens&#91;tokens.length-1];\n        const rightBox = &#91;];\n        \/\/console.log(kIdx)\n        \/\/console.log(target,'target')\n        \/\/console.log(box)\n       for(let i=0;i&lt; num; i++){\n         if(box&#91;i].split(\"\").sort().join(\"\")===target &amp;&amp; box&#91;i]!==target){\n            rightBox.push(box&#91;i]);\n         }\n       }\n       console.log(rightBox.length);\n       \/\/console.log(rightBox)\n       if(rightBox&#91;kIdx]){\n         console.log(rightBox&#91;kIdx-1])\n       }\n    }\n}()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u63cf\u8ff0 \u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32&nbsp;ss&nbsp;\u7684..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,11],"tags":[],"class_list":["post-588","post","type-post","status-publish","format-standard","hentry","category-js","category-front"],"featured_image_urls":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":""},"author_info":{"info":["\u9648 \u67d0\u4eba"]},"category_info":"<a href=\"https:\/\/mitongxue.cn\/index.php\/category\/front\/js\/\" rel=\"category tag\">JS<\/a> <a href=\"https:\/\/mitongxue.cn\/index.php\/category\/front\/\" rel=\"category tag\">\u524d\u7aef<\/a>","tag_info":"\u524d\u7aef","comment_count":"0","_links":{"self":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/comments?post=588"}],"version-history":[{"count":1,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/588\/revisions"}],"predecessor-version":[{"id":589,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/588\/revisions\/589"}],"wp:attachment":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/media?parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/categories?post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/tags?post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}